glxChooseFBConfig
returns GLXFBConfig*
and GLXFBConfig
is defined this way:
typedef struct __GLXFBConfigRec *GLXFBConfig;
Here is an example function which uses glxChooseFBConfig
and frees memory:
void fun()
{
const int attribs[] =
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
GLX_DOUBLEBUFFER, True,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
None
};
Display* dpy = XOpenDisplay(NULL);
int count = 0;
GLXFBConfig* fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), attribs, &count);
//do something with fbconfigs
for(int i = 0; i < count; ++i)
{
XFree(fbconfigs[i]);
}
XFree(fbconfigs);
}
I compile my application with flag -fsanitize=address
. When I run the application I get a sanitizer error: attempting double-free
What is wrong ?