#18 libmodplug freeing its argument doesn't seem right

None
closed-invalid
nobody
None
5
2014-03-10
2013-09-26
Ozkan Sezer
No

Around line 170 of sndfile.cpp, CSoundFile::Create() does:

#ifdef MMCMP_SUPPORT
if (bMMCmp)
{
GlobalFreePtr(lpStream);
lpStream = NULL;
}
#endif

MMCMP_SUPPORT is defined within the same file, so this part of the code frees the mem pointer passed to it by way of ModPlug_Load() which seems unsafe. You do not know what memory address is passed as lpStream: it need not be a malloc'ed memory at all, and the client need not be aware of the library's free'ing it either. Am I missing something?

Discussion

  • Ozkan Sezer
    Ozkan Sezer
    2013-09-26

    Ah. I just noticed that the unpacker replaces the pointer if it succeeds, so it is safe. Sorry for the noise, please close this as invalid.

     
  • Konstanty
    Konstanty
    2014-03-10

    • status: open --> closed-invalid
    • Group: -->