summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Rousseau <ludovic.rousseau+github@gmail.com>2013-09-22 21:29:50 +0200
committerLudovic Rousseau <ludovic.rousseau+github@gmail.com>2013-09-28 12:19:16 +0200
commitc4f2c353b9a1f6bc418dcd1d330d7c99084570d5 (patch)
treefa245a4d22ceb496eb4c76390fe2ba8d7f7d410c
parentc393574a0148a826e4be575c356b7b5724190c8c (diff)
downloadlibusb-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".
-rw-r--r--libusb/version_nano.h2
-rw-r--r--tests/testlib.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 2000b91..ac86199 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10842
+#define LIBUSB_NANO 10843
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;