GLShaderContext mixing malloc and delete

Bug #992049 reported by Andrew Wason
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Undecided
rdb

Bug Description

GLShaderContext::glsl_report_shader_errors() mallocs a message buffer but then deletes it with "delete[]" instead of free(). On Mac at least this causes the app to crash with a message like:

 Python(44890,0xad2852c0) malloc: *** error for object 0x6c9a62d4: pointer being freed was not allocated

Also the info_log pointer is uninitialized and is deleted even if not allocated, so we may delete a random pointer.

So this patch uses free() instead of delete[]. Also it only frees the buffer if it was allocated. And I changed the length check to >1 - the length returned for GL_INFO_LOG_LENGTH includes the NUL char, so length of 1 would mean an empty string (and this is what my Nvidia Quadro FX 580 on Ubuntu 11.10 always returns on success).

Revision history for this message
Andrew Wason (rectalogic) wrote :
Revision history for this message
rdb (rdb) wrote :

Thank you very much for the patch. I've applied it to the trunk and 1.8 branch. I've applied the same fix to the glsl_report_program_errors() method as well.

Changed in panda3d:
assignee: nobody → rdb (rdb)
milestone: none → 1.8.1
status: New → Fix Committed
rdb (rdb)
Changed in panda3d:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Patches

Remote bug watches

Bug watches keep track of this bug in other bug trackers.