Tests: dereference of NULL pointer on allocation failure
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 Jun 2016 11:21:29 +0000 (07:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 Jun 2016 11:24:31 +0000 (07:24 -0400)
Reported by Coverity as:
CID 1354904 (#1 of 1): Dereference null return value (NULL_RETURNS)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/lib/test_dwarf.c

index 95fd9e117ad8dbcede3282966ff2c87294016e01..90c1441e3fe6929bae72e5833914780707cdad31 100644 (file)
@@ -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");
This page took 0.025316 seconds and 4 git commands to generate.