dbghelp: do not write to array element -1(resend)

Peter Oberndorfer kumbayo84 at arcor.de
Wed Nov 8 14:24:52 CST 2006


kernel32.dll.so does not contain a ".debug_str" section here when compiled with -gstabs+ flag (0.9.23)
so it gets assigned section index -1
when elf_unmap_section tries to unmap section index -1, it corrupts heap
found with WINEDEBUG=+heap
and winedbg watch points

Changelog:
dbghelp: do not write to array element -1
-------------- next part --------------
From e8d8b9433fd4920408bfda09d126224899d1096a Mon Sep 17 00:00:00 2001
From: Peter Oberndorfer <kumbayo84 at arcor.de>
Date: Sat, 4 Nov 2006 18:51:27 +0100
Subject: [PATCH] dbghelp: do not write to array element -1
---
 dlls/dbghelp/elf_module.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index a509848..0c83984 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -162,7 +162,7 @@ static const char* elf_map_section(struc
  */
 static void elf_unmap_section(struct elf_file_map* fmap, int sidx)
 {
-    if (sidx < fmap->elfhdr.e_shnum && fmap->sect[sidx].mapped != NO_MAP)
+    if (sidx >= 0 && sidx < fmap->elfhdr.e_shnum && fmap->sect[sidx].mapped != NO_MAP)
     {
         munmap((char*)fmap->sect[sidx].mapped, fmap->sect[sidx].shdr.sh_size);
         fmap->sect[sidx].mapped = NO_MAP;
-- 
1.4.3.2



More information about the wine-patches mailing list