Permalink
Browse files

Fix memory AGG and OGR leaks on error (#5145)

  • Loading branch information...
gogglesguy authored and tbonfort committed Aug 19, 2015
1 parent d6d3432 commit 75d092a8eab8b51c72bd27aeb40bc275b312f56d
Showing with 11 additions and 0 deletions.
  1. +3 −0 mapagg.cpp
  2. +8 −0 mapogr.cpp
View
@@ -822,6 +822,8 @@ imageObj *agg2CreateImage(int width, int height, outputFormatObj *format, colorO
if( (AGG_INT64U)bufSize != bufSize64 ) {
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating " AGG_INT64U_FRMT " bytes.\n", "agg2CreateImage()",
__FILE__, __LINE__, bufSize64);
+ free(image);
+ delete r;
return NULL;
}
@@ -830,6 +832,7 @@ imageObj *agg2CreateImage(int width, int height, outputFormatObj *format, colorO
msSetError(MS_MEMERR, "%s: %d: Out of memory allocating " AGG_INT64U_FRMT " bytes.\n", "agg2CreateImage()",
__FILE__, __LINE__, bufSize64);
free(image);
+ delete r;
return NULL;
}
r->m_rendering_buffer.attach(r->buffer, width, height, width * 4);
View
@@ -901,6 +901,14 @@ static char **msOGRGetValues(layerObj *layer, OGRFeatureH hFeature)
msDebug(MSOGR_SYMBOLPARAMNAME " = \"%s\"\n", values[i]);
}
else {
+ msFreeCharArray(values,i);
+
+ OGR_SM_Destroy(hStyleMgr);
+ OGR_ST_Destroy(hLabelStyle);
+ OGR_ST_Destroy(hPenStyle);
+ OGR_ST_Destroy(hBrushStyle);
+ OGR_ST_Destroy(hSymbolStyle);
+
msSetError(MS_OGRERR,"Invalid field index!?!","msOGRGetValues()");
return(NULL);
}

0 comments on commit 75d092a

Please sign in to comment.