[PATCH] gdiplus: Fix memory leak in GdipLockBitmapBits.
Nathan Beckmann
nathan.beckmann at gmail.com
Fri Mar 7 01:08:04 CST 2008
Memory allocated in GdipLockBitmapBits wasn't kept track of for read
operations.
A bitmap that was disposed of before calling GdipUnlockBitmapBits
would leak this memory as well.
---
dlls/gdiplus/image.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 1694920..0297d7c 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -170,8 +170,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
bitmap->lockmode = flags;
bitmap->numlocks++;
- if(flags & ImageLockModeWrite)
- bitmap->bitmapbits = buff;
+ bitmap->bitmapbits = buff;
return Ok;
}
@@ -225,6 +224,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
}
GdipFree(bitmap->bitmapbits);
+ bitmap->bitmapbits = NULL;
return Ok;
}
@@ -426,6 +426,8 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
IPicture_get_CurDC(image->picture, &hdc);
DeleteDC(hdc);
IPicture_Release(image->picture);
+ if (image->type == ImageTypeBitmap)
+ GdipFree(((GpBitmap*)image)->bitmapbits);
GdipFree(image);
return Ok;
--
1.5.4.2
More information about the wine-patches
mailing list