Skip to content

Fix shader/program info log leak and new[]/delete mismatch in CoreGL.cpp - #341

Open
Abishek82828 wants to merge 1 commit into
gildor2:masterfrom
Abishek82828:fix/coregl-shader-log-leak-and-new-delete-mismatch
Open

Abishek82828 wants to merge 1 commit into
gildor2:masterfrom
Abishek82828:fix/coregl-shader-log-leak-and-new-delete-mismatch

Conversation

@Abishek82828

Copy link
Copy Markdown

CheckShader() and CheckProgram() in Core/CoreGL.cpp allocate infoLog with new char[infologLength], but on the FILTER_GLSL_SPAM early-return path — the common case, since it's hit whenever ATI or Intel drivers report a clean compile/link ("shader was successfully compiled", "no errors", "...linked") — the buffer was never freed. Since FILTER_GLSL_SPAM is enabled by default, this leaks infologLength bytes on essentially every successful shader/program compile on those GPU vendors.

On the non-leaking path, the buffer was freed with scalar delete infoLog; instead of delete[] infoLog;, which is undefined behavior for an array allocation.

Fix: free infoLog with delete[] on every return path in both functions.

Small, self-contained change, no behavior change on the non-leak path. Built and linked cleanly on VC++ (win64) before submitting.

CheckShader() and CheckProgram() allocate infoLog with 'new char[infologLength]'
but on the FILTER_GLSL_SPAM early-return path (the common case: ATI/Intel
drivers reporting a clean compile/link) the buffer was never freed, leaking
memory on essentially every successful shader compile on those GPUs. The
non-leaking path also freed it with scalar 'delete' instead of 'delete[]',
which is undefined behavior for an array allocation.

Fixed both functions to free infoLog with delete[] on every return path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant