dbghelp: Fixed memory leak in source string handling.
This commit is contained in:
parent
a519d104a8
commit
76e8b504c1
|
@ -56,7 +56,6 @@ static unsigned source_find(const struct module* module, const char* name)
|
|||
*/
|
||||
unsigned source_new(struct module* module, const char* base, const char* name)
|
||||
{
|
||||
int len;
|
||||
unsigned ret;
|
||||
const char* full;
|
||||
char* tmp = NULL;
|
||||
|
@ -75,10 +74,9 @@ unsigned source_new(struct module* module, const char* base, const char* name)
|
|||
if (tmp[bsz - 1] != '/') tmp[bsz++] = '/';
|
||||
strcpy(&tmp[bsz], name);
|
||||
}
|
||||
if (module->sources && (ret = source_find(module, full)) != (unsigned)-1)
|
||||
return ret;
|
||||
|
||||
len = strlen(full) + 1;
|
||||
if (!module->sources || (ret = source_find(module, full)) == (unsigned)-1)
|
||||
{
|
||||
int len = strlen(full) + 1;
|
||||
if (module->sources_used + len + 1 > module->sources_alloc)
|
||||
{
|
||||
/* Alloc by block of 256 bytes */
|
||||
|
@ -90,9 +88,10 @@ unsigned source_new(struct module* module, const char* base, const char* name)
|
|||
module->sources_alloc);
|
||||
}
|
||||
ret = module->sources_used;
|
||||
strcpy(module->sources + module->sources_used, full);
|
||||
memcpy(module->sources + module->sources_used, full, len);
|
||||
module->sources_used += len;
|
||||
module->sources[module->sources_used] = '\0';
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, tmp);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue