L3DT users' community
Large 3D terrain generator

LibHFZ memory leaks

Please report software faults here.

LibHFZ memory leaks

Postby gregery » Sun Sep 07, 2008 1:26 am

Need to be free from mem block dumps,

long hfzReadHeader(hfzFile* fs, hfzHeader& fh) {
...
if(hl) {

char* pBuf;
if(!(pBuf = (char*)hfzMalloc(hl))) {
return LIBHFZ_ERROR_ALLOC_FAILED;
}

if(hl!=hfzRead(fs, pBuf, hl)) {
hfzFree(pBuf);
return LIBHFZ_ERROR_READ_FAILED;
}

long rval = hfzHeader_DecodeExtHeaderBuf(fh, pBuf);
if(rval<0) {
hfzFree(pBuf);
return rval;
}

// added: pBuf is mem copied in calls, so only a temp buffer

hfzFree(pBuf);
}

and I found this but bigendian is for toy computers anyway

long hfzByteSwap(void* pData, unsigned long DataSize) {
if(!pData) return LIBHFZ_ERROR_INVALID_HANDLE;
if(!DataSize) return LIBHFZ_ERROR_INVALID_PARAM;

void* pSwap = hfzMalloc(DataSize);
if(!pSwap) return LIBHFZ_ERROR_ALLOC_FAILED;

// re-sort into swap
for(unsigned long i=0; i<DataSize; i++) {
((char*)pSwap)[i] = ((char*)pData)[DataSize - i - 1];
}

// now copy back
hfzMemcpy(pData, pSwap, DataSize);

// Added: Don't need this temp buffer anymore

hfzFree(pSwap);

return LIBHFZ_STATUS_OK;
}
gregery
New member
 
Posts: 3
Joined: Sun Sep 07, 2008 1:01 am

Postby Aaron » Sun Sep 07, 2008 8:27 am

Hi Gregery,

Thank-you very much for spotting those bugs. I've upload an updated LibHFZ with the fixes for those two memory leaks. Thanks again!

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to Bug reports

Who is online

Users browsing this forum: No registered users and 13 guests

cron