Bugzilla – Bug 572
Memory leak after using _ktxUnpackETC (also no result status check)
Last modified: 2012-01-17 19:18:38 PST
Created attachment 91 [details] Patch for loader.c to fix memory leak (and check result code) After successful _ktxUnpackETC call (in loader.c), memory allocated for 'unpacked' variable (inside function) is not released after using, so leaking memory - in my case total leak is about 0,5MB per mip-mapped texture: _ktxUnpackETC(data, &unpacked, pixelWidth, pixelHeight); glTexImage2D(texinfo.glTarget + face, level, GL_RGB, pixelWidth, pixelHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, unpacked); Also there is no result code check. Suggested fix (also as a patch in attachment): errorCode = _ktxUnpackETC(data, &unpacked, pixelWidth, pixelHeight); if (errorCode != KTX_SUCCESS) { goto cleanup; } glTexImage2D(texinfo.glTarget + face, level, GL_RGB, pixelWidth, pixelHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, unpacked); free(unpacked);
In SVN r16605.