From c4f2c353b9a1f6bc418dcd1d330d7c99084570d5 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Sun, 22 Sep 2013 21:29:50 +0200 Subject: 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". --- libusb/version_nano.h | 2 +- tests/testlib.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3