[PATCH] win32u: Fix memory leak on error path in PATH_WidenPath (cppcheck)

Alex Henrie alexhenrie24 at gmail.com
Sun Dec 19 22:56:56 CST 2021


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/win32u/path.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/win32u/path.c b/dlls/win32u/path.c
index 05123a2f2e4..ada76bb4a7a 100644
--- a/dlls/win32u/path.c
+++ b/dlls/win32u/path.c
@@ -1616,7 +1616,7 @@ BOOL WINAPI NtGdiFlattenPath( HDC hdc )
 static struct gdi_path *PATH_WidenPath(DC *dc)
 {
     INT i, j, numStrokes, penWidth, penWidthIn, penWidthOut, size, penStyle;
-    struct gdi_path *flat_path, *pNewPath, **pStrokes = NULL, *pUpPath, *pDownPath;
+    struct gdi_path *flat_path, *pNewPath, **pStrokes = NULL, **pNewStrokes, *pUpPath, *pDownPath;
     EXTLOGPEN *elp;
     BYTE *type;
     DWORD obj_type, joint, endcap, penType;
@@ -1681,12 +1681,14 @@ static struct gdi_path *PATH_WidenPath(DC *dc)
             case PT_MOVETO:
                 numStrokes++;
                 j = 0;
-                pStrokes = realloc( pStrokes, numStrokes * sizeof(*pStrokes) );
-                if(!pStrokes)
+                pNewStrokes = realloc( pStrokes, numStrokes * sizeof(*pStrokes) );
+                if(!pNewStrokes)
                 {
                     free_gdi_path(flat_path);
+                    free(pStrokes);
                     return NULL;
                 }
+                pStrokes = pNewStrokes;
                 pStrokes[numStrokes - 1] = alloc_gdi_path(0);
                 /* fall through */
             case PT_LINETO:
-- 
2.34.1




More information about the wine-devel mailing list