When d_size is zero d_buf might be NULL.

Signed-off-by: Mark Wielaard <[email protected]>
---
 src/ChangeLog | 4 ++++
 src/elfcmp.c  | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 3161aa8..59d87c8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-30  Mark Wielaard  <[email protected]>
+
+       * elfcmp.c (main): Only call memcmp when d_size != 0.
+
 2015-05-23  Mark Wielaard  <[email protected]>
 
        * Makefile.am: Define ldgeneric, readelf, nm, size, strip, elflint,
diff --git a/src/elfcmp.c b/src/elfcmp.c
index f8a4572..0250fbe 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -1,5 +1,5 @@
 /* Compare relevant content of two ELF files.
-   Copyright (C) 2005-2012, 2014 Red Hat, Inc.
+   Copyright (C) 2005-2012, 2014, 2015 Red Hat, Inc.
    This file is part of elfutils.
    Written by Ulrich Drepper <[email protected]>, 2005.
 
@@ -511,6 +511,7 @@ cannot read note section [%zu] '%s' in '%s': %s"),
 
          if (unlikely (data1->d_size != data2->d_size
                        || (shdr1->sh_type != SHT_NOBITS
+                           && data1->d_size != 0
                            && memcmp (data1->d_buf, data2->d_buf,
                                       data1->d_size) != 0)))
            {
-- 
2.1.0

Reply via email to