From c26d30a1726a68c148e3cfa82564deb5f208a398 Mon Sep 17 00:00:00 2001 From: kaiw Date: Tue, 14 Feb 2012 19:48:57 +0000 Subject: [PATCH] MFC r221595: For zero-sized sections, set the `d_buf` field of the `Elf_Data` descriptor returned by `elf_rawdata()` to NULL. git-svn-id: svn://svn.freebsd.org/base/stable/8@231703 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libelf/elf_data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libelf/elf_data.c b/lib/libelf/elf_data.c index 9241b09dc..99098011b 100644 --- a/lib/libelf/elf_data.c +++ b/lib/libelf/elf_data.c @@ -223,7 +223,8 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d) if ((d = _libelf_allocate_data(s)) == NULL) return (NULL); - d->d_buf = sh_type == SHT_NOBITS ? NULL : e->e_rawfile + sh_offset; + d->d_buf = (sh_type == SHT_NOBITS || sh_size == 0) ? NULL : + e->e_rawfile + sh_offset; d->d_off = 0; d->d_align = sh_align; d->d_size = sh_size; -- 2.45.0