This prevents leaks and makes sure all data are available.
In case there is only one section it works as before.

Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>
---

This might break stuff if something relied on previous rodata locations.

 src/gallium/drivers/radeon/radeon_elf_util.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_elf_util.c 
b/src/gallium/drivers/radeon/radeon_elf_util.c
index 9b50822..a117f61 100644
--- a/src/gallium/drivers/radeon/radeon_elf_util.c
+++ b/src/gallium/drivers/radeon/radeon_elf_util.c
@@ -153,9 +153,12 @@ void radeon_elf_read(const char *elf_data, unsigned 
elf_size,
                                                  (char *)section_data->d_buf);
                } else if (!strncmp(name, ".rodata", 7)) {
                        section_data = elf_getdata(section, section_data);
-                       binary->rodata_size = section_data->d_size;
-                       binary->rodata = MALLOC(binary->rodata_size * 
sizeof(unsigned char));
-                       memcpy(binary->rodata, section_data->d_buf, 
binary->rodata_size);
+                       binary->rodata = REALLOC(binary->rodata,
+                                        binary->rodata_size,
+                                        binary->rodata_size + 
section_data->d_size);
+                       memcpy(binary->rodata + binary->rodata_size,
+                              section_data->d_buf, section_data->d_size);
+                       binary->rodata_size += section_data->d_size;
                } else if (!strncmp(name, ".symtab", 7)) {
                        symbols = elf_getdata(section, section_data);
                        symbol_sh_link = section_header.sh_link;
-- 
2.1.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to