* Do not try to free() on buffers that have been allocated with the real
malloc, or we may crash unexpectedly, for instance if dlsym("free") calls
malloc() then free() while free hasn't been loaded yet.
This commit is contained in:
+7
-1
@@ -110,6 +110,7 @@ static int64_t dummy_offset = 0;
|
||||
|
||||
void _zz_mem_init(void)
|
||||
{
|
||||
LOADSYM(free);
|
||||
LOADSYM(calloc);
|
||||
LOADSYM(malloc);
|
||||
LOADSYM(realloc);
|
||||
@@ -156,7 +157,12 @@ void NEW(free)(void *ptr)
|
||||
debug("%s(%p)", __func__, ptr);
|
||||
return;
|
||||
}
|
||||
LOADSYM(free);
|
||||
if(!ORIG(free))
|
||||
{
|
||||
/* FIXME: memory leak */
|
||||
debug("%s(%p) IGNORED", __func__, ptr);
|
||||
return;
|
||||
}
|
||||
ORIG(free)(ptr);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -102,13 +102,13 @@ void _zz_init(void)
|
||||
{
|
||||
char *tmp, *tmp2;
|
||||
|
||||
/* We need this as soon as possible */
|
||||
_zz_mem_init();
|
||||
|
||||
tmp = getenv("ZZUF_DEBUG");
|
||||
if(tmp)
|
||||
_zz_debugfd = atoi(tmp);
|
||||
|
||||
/* We need this as soon as possible */
|
||||
_zz_mem_init();
|
||||
|
||||
tmp = getenv("ZZUF_SEED");
|
||||
if(tmp && *tmp)
|
||||
_zz_setseed(atol(tmp));
|
||||
|
||||
Reference in New Issue
Block a user