From: Jiajin Cui cuijiajin@uniontech.com
Added proper cleanup for allocated memory when matrix inversion fails in GdipDrawImagePointsRect function. Previously, if GdipInvertMatrix returned an error status, the function would return immediately without freeing the src_data buffer that was allocated earlier in the function, causing a memory leak.
This fix ensures that src_data is properly freed before returning when matrix inversion fails, preventing memory leaks in error conditions.
Signed-off-by: Jiajin Cui cuijiajin@uniontech.com --- dlls/gdiplus/graphics.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 1c7e3bde09c..2419eea94db 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -3400,7 +3400,11 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image GdipSetMatrixElements(&dst_to_src, m11, m12, m21, m22, mdx, mdy);
stat = GdipInvertMatrix(&dst_to_src); - if (stat != Ok) return stat; + if (stat != Ok) + { + free(src_data); + return stat; + }
dst_stride = sizeof(ARGB) * (dst_area.right - dst_area.left); x_dx = dst_to_src.matrix[0];