#154 Freeing invalid pointer

gl... Functions
closed-fixed
Defect (99)
5
2005-05-26
2005-05-24
No

I encountered a problem when developing an application
using the Vincent ogles library; it crasched when I
made what appeared to be valid calls to glBufferData().
I checked the source and discovered that buffers are
managed using the class Buffer declared in the file
$DIST_ROOT/src/Buffer.h. Upon allocating memory for a
buffer, the Buffer object automatically deallocates
previously allocated memory. The problem is that Buffer
objects doesn't initialize its data pointer to NULL
when a Buffer object is created.

The class currently looks like this (in the latest dist
as of 24th May 2005):

class Buffer {
public:
Buffer() { }
.
.
.
void Deallocate() {
if (m_Data) {
free(m_Data);
m_Data = 0;
m_Size = 0;
}
}
.
.
.
private:
void * m_Data;
size_t m_Size;
};

As m_Data isn't initialized to NULL in the constructor,
freeing of an invalid pointer is rather likely. By
changing the constructor to:

Buffer(): mData(0), m_Size(0) { }

things seem to work a lot better.

Hope this helps!

Discussion

  • Hans-Martin Will

    • status: open --> open-fixed
     
  • Hans-Martin Will

    Logged In: YES
    user_id=618887

    Yes, this has been fixed in November (file version 1.3).
    Looks like time to build a redistribution.

     
  • Hans-Martin Will

    • assigned_to: nobody --> hmwill
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks