]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: Use error, not assert, when trying to print a non-base type DIE.
authorMark Wielaard <mark@klomp.org>
Wed, 6 Jun 2018 21:35:35 +0000 (23:35 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 8 Jun 2018 10:03:14 +0000 (12:03 +0200)
When using the varlocs test with a fuzzer using assert for internal
sanity checks is great to find issues. But when encountering bad data
using an assert is wrong. Just use error to show we handle the data
correctly (by reporting it is bad, instead of crashing).

Signed-off-by: Mark Wielaard <mark@klomp.org>
tests/ChangeLog
tests/varlocs.c

index a7b8da72bab9c99b034aa890df5e13d22b80803f..587e2ac9b82d470fb5b1ab467926efdf73bab1ed 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-06  Mark Wielaard  <mark@klomp.org>
+
+       * varlocs.c (print_base_type): Use error, not assert when the DIE
+       isn't a base type.
+
 2018-06-02  Mark Wielaard  <mark@klomp.org>
 
        * test-subr.sh (self_test_files_exe): Drop shared libraries.
index 31a1069a95ea43d1aa53c0c6d7a42a53e42e503f..2ddd3d8f3e78039d207c10bf0cdb70b6f77d7493 100644 (file)
@@ -122,7 +122,8 @@ dwarf_form_string (unsigned int form)
 static void
 print_base_type (Dwarf_Die *base)
 {
-  assert (dwarf_tag (base) == DW_TAG_base_type);
+  if (dwarf_tag (base) != DW_TAG_base_type)
+    error (EXIT_FAILURE, 0, "not a base type");
 
   Dwarf_Attribute encoding;
   Dwarf_Word enctype = 0;