Commit 2c28fa54 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

test/json_util_ut: assert that string is valid



Make sure the output.my_name pointer is not NULL before calling memcmp()
on it.  Fixes static analysis warning about a potential NULL pointer
dereference.

Change-Id: I85faf57c63b0760c4f90d9ee99f6d7e3df121211
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/369264


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent cb29ce86
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ test_decode_object(void)

	/* Passing Test: object containing simple types */
	CU_ASSERT(spdk_json_decode_object(object, decoders, 4, &output) == 0);
	SPDK_CU_ASSERT_FATAL(output.my_name != NULL);
	CU_ASSERT(memcmp(output.my_name, answer_str, 6) == 0);
	CU_ASSERT(output.my_int == answer);
	CU_ASSERT(output.my_bool == answer_bool);