gdiplus: Fix image leak in graphics test.

Vincent Povirk madewokherd at gmail.com
Tue Apr 29 13:11:34 CDT 2014


For bug 36132.
-------------- next part --------------
From c5b3a19b240e6720ada0f7a495372ca56d2ea888 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 29 Apr 2014 13:08:02 -0500
Subject: [PATCH] gdiplus: Fix image leak in graphics test.

---
 dlls/gdiplus/tests/graphics.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 9fb1347..bd227dc 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -92,7 +92,7 @@ static REAL units_scale(GpUnit from, GpUnit to, REAL dpi)
     return pixels_to_units(pixels, to, dpi);
 }
 
-static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL scale)
+static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL scale, GpImage **image)
 {
     GpStatus status;
     union
@@ -117,11 +117,8 @@ static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL sca
 
     status = GdipGetImageGraphicsContext(u.image, &graphics);
     expect(Ok, status);
-    /* image is intentionally leaked to make sure that there is no
-       side effects after its destruction.
-    status = GdipDisposeImage(u.image);
-    expect(Ok, status);
-    */
+
+    *image = u.image;
 
     status = GdipGetDpiX(graphics, &res);
     expect(Ok, status);
@@ -3519,7 +3516,9 @@ static void test_GdipMeasureString(void)
 
     for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
     {
-        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale);
+        GpImage *image;
+
+        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
 
         lf.lfHeight = 0xdeadbeef;
         status = GdipGetLogFontW(font, graphics, &lf);
@@ -3570,6 +3569,9 @@ todo_wine
 
         status = GdipDeleteGraphics(graphics);
         expect(Ok, status);
+
+        status = GdipDisposeImage(image);
+        expect(Ok, status);
     }
 
     GdipDeleteFont(font);
@@ -3593,8 +3595,9 @@ todo_wine
         for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
         {
             REAL unit_scale;
+            GpImage *image;
 
-            graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale);
+            graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].page_scale, &image);
 
             lf.lfHeight = 0xdeadbeef;
             status = GdipGetLogFontW(font, graphics, &lf);
@@ -3664,6 +3667,9 @@ todo_wine
 
             status = GdipDeleteGraphics(graphics);
             expect(Ok, status);
+
+            status = GdipDisposeImage(image);
+            expect(Ok, status);
         }
 
         GdipDeleteFont(font);
@@ -3701,12 +3707,13 @@ static void test_transform(void)
     };
     GpStatus status;
     GpGraphics *graphics;
+    GpImage *image;
     GpPointF ptf[2];
     UINT i;
 
     for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
     {
-        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale);
+        graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale, &image);
         ptf[0].X = td[i].in[0].X;
         ptf[0].Y = td[i].in[0].Y;
         ptf[1].X = td[i].in[1].X;
@@ -3725,6 +3732,8 @@ static void test_transform(void)
         expectf(td[i].in[1].Y, ptf[1].Y);
         status = GdipDeleteGraphics(graphics);
         expect(Ok, status);
+        status = GdipDisposeImage(image);
+        expect(Ok, status);
     }
 }
 
-- 
1.8.3.2



More information about the wine-patches mailing list