diff options
author | Nick Clifton <nickc@redhat.com> | 2016-09-06 15:42:12 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2016-09-06 15:42:12 +0100 |
commit | 21b65bac42c899df2049cdbd472b2e7242a40fbe (patch) | |
tree | a50524f920a87b6e7bbc70a136a9a666d620cb19 /binutils/readelf.c | |
parent | bf1865065f64af2f32798c0327143baf99634e8d (diff) | |
download | gdb-21b65bac42c899df2049cdbd472b2e7242a40fbe.zip gdb-21b65bac42c899df2049cdbd472b2e7242a40fbe.tar.gz gdb-21b65bac42c899df2049cdbd472b2e7242a40fbe.tar.bz2 |
Fix a problem in readelf where memcpy could be called with a NULL second argument.
* readelf.c (request_dump_bynumber): Only call memcpy if
dump_sects is not NULL.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r-- | binutils/readelf.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c index a99c521..c9bce2e 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -4238,10 +4238,13 @@ request_dump_bynumber (unsigned int section, dump_type type) error (_("Out of memory allocating dump request table.\n")); else { - /* Copy current flag settings. */ - memcpy (new_dump_sects, dump_sects, num_dump_sects * sizeof (* dump_sects)); + if (dump_sects) + { + /* Copy current flag settings. */ + memcpy (new_dump_sects, dump_sects, num_dump_sects * sizeof (* dump_sects)); - free (dump_sects); + free (dump_sects); + } dump_sects = new_dump_sects; num_dump_sects = section + 1; |