* don't leak the rect data in case of failed realloc()

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22006 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2007-08-17 16:24:43 +00:00
parent 15a6a1bd6d
commit ae3a7f4dac

View File

@ -471,9 +471,15 @@ BRegion::_SetSize(long newSize)
if (fData == &fBounds) {
fData = (clipping_rect*)malloc(newSize * sizeof(clipping_rect));
fData[0] = fBounds;
} else if (fData)
fData = (clipping_rect*)realloc(fData, newSize * sizeof(clipping_rect));
else
} else if (fData) {
clipping_rect* resizedData = (clipping_rect*)realloc(fData,
newSize * sizeof(clipping_rect));
if (!resizedData) {
free(fData);
fData = NULL;
} else
fData = resizedData;
} else
fData = (clipping_rect*)malloc(newSize * sizeof(clipping_rect));
} else {
// just an empty region, but no error