diff options
author | Mark Wielaard <mark@klomp.org> | 2020-06-11 23:16:21 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2020-06-11 23:16:21 +0200 |
commit | 50a6eeef7d87623faa65126dc3d16c2a8e613aea (patch) | |
tree | 19a35135efaac56c49a30316c6572c7b4d6ec4aa /tests/elfputzdata.c | |
parent | 49f13584d60322578c19b6118393ab04236ca7bf (diff) | |
parent | a2bc0214a5615551d89cef8d160bdbaafd5f1a83 (diff) |
Merge tag 'elfutils-0.180' into mjw/RH-DTSdts-0.180
elfutils 0.180 release
Diffstat (limited to 'tests/elfputzdata.c')
-rw-r--r-- | tests/elfputzdata.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/elfputzdata.c b/tests/elfputzdata.c index 66ab77ba..0d9c020e 100644 --- a/tests/elfputzdata.c +++ b/tests/elfputzdata.c @@ -105,14 +105,17 @@ main (int argc, char *argv[]) printf ("Unexpected data size for orig section %zd\n", idx); return -1; } - char *orig_buf = malloc (d->d_size); - if (orig_size > 0 && orig_buf == NULL) + char *orig_buf = NULL; + if (orig_size > 0) { - printf ("No memory to copy section %zd data\n", idx); - return -1; + orig_buf = malloc (d->d_size); + if (orig_buf == NULL) + { + printf ("No memory to copy section %zd data\n", idx); + return -1; + } + memcpy (orig_buf, d->d_buf, orig_size); } - if (orig_size > 0) - memcpy (orig_buf, d->d_buf, orig_size); bool forced = false; if (gnu) @@ -175,7 +178,8 @@ main (int argc, char *argv[]) } if (new_size == orig_size - && memcmp (orig_buf, d->d_buf, orig_size) == 0) + && (orig_buf == NULL + || memcmp (orig_buf, d->d_buf, orig_size) == 0)) { printf ("section %zd didn't compress\n", idx); return -1; @@ -211,7 +215,8 @@ main (int argc, char *argv[]) return -1; } if (newer_size != orig_size - && memcmp (orig_buf, d->d_buf, orig_size) != 0) + && (orig_buf == NULL + || memcmp (orig_buf, d->d_buf, orig_size) != 0)) { printf ("section %zd didn't correctly uncompress\n", idx); return -1; |