[directfb-users] Memleak on IDirectFBSurface->Clear on X11

Holger Freyther holger at freyther.de
Sun Oct 23 14:32:24 CEST 2011


Holger Freyther <holger at ...> writes:

Hi,

here is a minimal example. How should I properly release
the surface and anything that is attached to it?

1.) valgrind shows use after free in the windowstack
2.) IDirectFBSurface->Clear() creates a memory leak, this is with
    directfb-1.4 as of today.


#include <directfb.h>

int main(int argc, char **argv)
{
    DFBResult  ret;
    IDirectFB *dfb;
    IDirectFBSurface *surface;

    /* Initialize DirectFB. */
    ret = DirectFBInit( &argc, &argv );
    if (ret) {
        D_DERROR( ret, "DFBTest/Resize: DirectFBInit() failed!\n" );
        return ret;
    }

    /* Create super interface. */
    ret = DirectFBCreate( &dfb );
    if (ret) {
        D_DERROR( ret, "DFBTest/Resize: DirectFBCreate() failed!\n" );
        return ret;
    }

    DFBSurfaceDescription surfaceDesc;
    memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription));
    surfaceDesc.width = 100;
    surfaceDesc.height = 200;
    
    surfaceDesc.caps = DSCAPS_PREMULTIPLIED;
    surfaceDesc.pixelformat = DSPF_ARGB;
    surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH |
        DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT);
        

    for (int i = 0; i < 10; ++i) {
        dfb->CreateSurface(dfb , &surfaceDesc, &surface);
        surface->Clear(surface, 0, 0, 0, 0);
        surface->Release(surface); 
    }   
    
    dfb->Release(dfb);
    return 0;
}






More information about the directfb-users mailing list