Module: wine Branch: master Commit: cbd5811e90c13e2a0ba563140d6315b338b88050 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cbd5811e90c13e2a0ba563140d...
Author: Eric Pouech eric.pouech@orange.fr Date: Sat Jan 8 14:15:25 2011 +0100
dbghelp: Better support for OOM conditions when creating source file table.
---
dlls/dbghelp/source.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/source.c b/dlls/dbghelp/source.c index c8ecf26..92c68b7 100644 --- a/dlls/dbghelp/source.c +++ b/dlls/dbghelp/source.c @@ -73,27 +73,31 @@ unsigned source_new(struct module* module, const char* base, const char* name) } if (!module->sources || (ret = source_find(module, full)) == (unsigned)-1) { + char* new; int len = strlen(full) + 1; if (module->sources_used + len + 1 > module->sources_alloc) { if (!module->sources) { module->sources_alloc = (module->sources_used + len + 1 + 255) & ~255; - module->sources = HeapAlloc(GetProcessHeap(), 0, module->sources_alloc); + new = HeapAlloc(GetProcessHeap(), 0, module->sources_alloc); } else { module->sources_alloc = max( module->sources_alloc * 2, (module->sources_used + len + 1 + 255) & ~255 ); - module->sources = HeapReAlloc(GetProcessHeap(), 0, module->sources, - module->sources_alloc); + new = HeapReAlloc(GetProcessHeap(), 0, module->sources, + module->sources_alloc); } + if (!new) goto done; + module->sources = new; } ret = module->sources_used; memcpy(module->sources + module->sources_used, full, len); module->sources_used += len; module->sources[module->sources_used] = '\0'; } +done: HeapFree(GetProcessHeap(), 0, tmp); return ret; }