Changeset 2354


Ignore:
Timestamp:
Jun 10, 2008, 6:21:17 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • 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.
Location:
zzuf/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/lib-mem.c

    r1791 r2354  
    111111void _zz_mem_init(void)
    112112{
     113    LOADSYM(free);
    113114    LOADSYM(calloc);
    114115    LOADSYM(malloc);
     
    157158        return;
    158159    }
    159     LOADSYM(free);
     160    if(!ORIG(free))
     161    {
     162        /* FIXME: memory leak */
     163        debug("%s(%p) IGNORED", __func__, ptr);
     164        return;
     165    }
    160166    ORIG(free)(ptr);
    161167}
  • zzuf/trunk/src/libzzuf.c

    r2345 r2354  
    103103    char *tmp, *tmp2;
    104104
    105     /* We need this as soon as possible */
    106     _zz_mem_init();
    107 
    108105    tmp = getenv("ZZUF_DEBUG");
    109106    if(tmp)
    110107        _zz_debugfd = atoi(tmp);
     108
     109    /* We need this as soon as possible */
     110    _zz_mem_init();
    111111
    112112    tmp = getenv("ZZUF_SEED");
Note: See TracChangeset for help on using the changeset viewer.