[PATCH 0/1] MR9420: gdiplus: add memory cleanup on matrix inversion failure
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(a)uniontech.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9420
From: Jiajin Cui <cuijiajin(a)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(a)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]; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9420
This merge request was approved by Esme Povirk. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9420
participants (3)
-
Esme Povirk (@madewokherd) -
Jiajin Cui -
Jiajin Cui (@jin-king1)