Antonio: Memory Leak in DipWrite
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Antonio, i found, that in this function pDip should released with
- Code: Select all Expand view
- hb_xfree( ( char * ) pDib );
- Code: Select all Expand view
- BOOL DibWrite( LPSTR szFileName, HGLOBAL hDIB )
{
long lSize;
char * pDib;
int hBmp;
pDib = DibToStr( hDIB, &lSize );
#ifndef UNICODE
if( ( hBmp = _lcreat( szFileName, 0 ) ) != HFILE_ERROR )
{
_hwrite( hBmp, ( const char * ) pDib, lSize );
_lclose( hBmp );
GlobalUnlock( hDIB );
hb_xfree( ( char * ) pDib );
return TRUE;
}
#else
if( ( hBmp = hb_fsCreate( ( unsigned char * ) szFileName, 0 ) ) != ( int ) INVALID_HANDLE_VALUE )
{
hb_fsWriteLarge( hBmp, ( unsigned char * ) pDib, lSize );
hb_fsClose( hBmp );
GlobalUnlock( hDIB );
hb_xfree( ( char * ) pDib );
return TRUE;
}
#endif
else
{
GlobalUnlock( hDIB );
hb_xfree( ( char * ) pDib );
return FALSE;
}
}