From 285fd56cebb6b02bb252bdce247efe3ba01bb2be Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 3 Jun 2016 07:21:29 -0400 Subject: [PATCH] Tests: dereference of NULL pointer on allocation failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reported by Coverity as: CID 1354904 (#1 of 1): Dereference null return value (NULL_RETURNS) Signed-off-by: Jérémie Galarneau --- tests/lib/test_dwarf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/lib/test_dwarf.c b/tests/lib/test_dwarf.c index 95fd9e11..90c1441e 100644 --- a/tests/lib/test_dwarf.c +++ b/tests/lib/test_dwarf.c @@ -55,6 +55,9 @@ void test_bt_dwarf(const char *data_dir) ok(ret == 0, "bt_dwarf_cu_next successful"); die = bt_dwarf_die_create(cu); ok(die != NULL, "bt_dwarf_die_create successful"); + if (!die) { + exit(EXIT_FAILURE); + } /* * Test bt_dwarf_die_next twice, as the code path is different * for DIEs at depth 0 (just created) and other depths. @@ -72,6 +75,10 @@ void test_bt_dwarf(const char *data_dir) /* Reset DIE to test dwarf_child */ bt_dwarf_die_destroy(die); die = bt_dwarf_die_create(cu); + if (!die) { + diag("Failed to create bt_dwarf_die"); + exit(EXIT_FAILURE); + } ret = bt_dwarf_die_child(die); ok(ret == 0, "bt_dwarf_die_child successful"); -- 2.34.1