Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mapshape, mapxbase: fix several memory leaks in error code paths
Leak bug found with libFuzzer.
  • Loading branch information
MaxKellermann authored and rouault committed May 4, 2021
1 parent b5c0e29 commit 5e4c504
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions mapshape.c
Expand Up @@ -1756,6 +1756,7 @@ int msShapefileOpen(shapefileObj *shpfile, const char *mode, const char *filenam
if( log_failures )
msSetError(MS_IOERR, "(%s)", "msShapefileOpen()", dbfFilename);
free(dbfFilename);
msSHPClose(shpfile->hSHP);
return(-1);
}
free(dbfFilename);
Expand Down
2 changes: 2 additions & 0 deletions mapxbase.c
Expand Up @@ -192,6 +192,7 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
pabyBuf = (uchar *) msSmallMalloc(500);
if( VSIFReadL( pabyBuf, 32, 1, psDBF->fp ) != 1 )
{
VSIFCloseL( psDBF->fp );
msFree(psDBF);
msFree(pabyBuf);
return( NULL );
Expand All @@ -217,6 +218,7 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess )
if( VSIFReadL( pabyBuf, nHeadLen - 32, 1, psDBF->fp ) != 1 )
{
msFree(psDBF->pszCurrentRecord);
VSIFCloseL( psDBF->fp );
msFree(psDBF);
msFree(pabyBuf);
return( NULL );
Expand Down

0 comments on commit 5e4c504

Please sign in to comment.