diff options
author | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-09-22 21:29:50 +0200 |
---|---|---|
committer | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-09-28 12:19:16 +0200 |
commit | c4f2c353b9a1f6bc418dcd1d330d7c99084570d5 (patch) | |
tree | fa245a4d22ceb496eb4c76390fe2ba8d7f7d410c /tests | |
parent | c393574a0148a826e4be575c356b7b5724190c8c (diff) | |
download | libusb-c4f2c353b9a1f6bc418dcd1d330d7c99084570d5.tar.gz |
tests: set output_file to a valid value
If fdopen(3) fails then ctx->output_file is NULL and should not be used
in cleanup_test_output() called next.
Problem detected by the Coverity tool
CID 1042543 (#1 of 1): Dereference after null check (FORWARD_NULL)9.
var_deref_model: Passing "ctx" to function
"cleanup_test_output(libusbx_testlib_ctx *)", which dereferences null
"ctx->output_file".
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testlib.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/testlib.c b/tests/testlib.c index e69aa39..7cab0b9 100644 --- a/tests/testlib.c +++ b/tests/testlib.c @@ -139,6 +139,7 @@ static int setup_test_output(libusbx_testlib_ctx * ctx) } ctx->output_file = fdopen(ctx->old_stdout, "w"); if (!ctx->output_file) { + ctx->output_file = stdout; cleanup_test_output(ctx); printf("Failed to open FILE for output handle: %d\n", errno); return 1; |