Huw Davies : riched20: Correctly release the STGMEDIUM.

Alexandre Julliard julliard at winehq.org
Thu Sep 14 14:50:09 CDT 2017


Module: wine
Branch: master
Commit: 9249f7c4e709dab009d2c87a0826c7ffb7f31b6e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9249f7c4e709dab009d2c87a0826c7ffb7f31b6e

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Sep 14 12:51:02 2017 +0100

riched20: Correctly release the STGMEDIUM.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/richole.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 98cee74..335b244 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -5257,6 +5257,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
       return;
     }
   }
+  IDataObject_Release(ido);
 
   switch (stgm.tymed)
   {
@@ -5264,19 +5265,17 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
     GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
     pSize->cx = dibsect.dsBm.bmWidth;
     pSize->cy = dibsect.dsBm.bmHeight;
-    if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
     break;
   case TYMED_ENHMF:
     GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
     pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
     pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
-    if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
     break;
   default:
     FIXME("Unsupported tymed %d\n", stgm.tymed);
     break;
   }
-  IDataObject_Release(ido);
+  ReleaseStgMedium(&stgm);
   if (c->editor->nZoomNumerator != 0)
   {
     pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
@@ -5294,6 +5293,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
   HDC           hMemDC;
   SIZE          sz;
   BOOL          has_size;
+  HBITMAP       old_bm;
 
   assert(run->nFlags & MERF_GRAPHICS);
   assert(run->ole_obj);
@@ -5319,12 +5319,14 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
       return;
     }
   }
+  IDataObject_Release(ido);
+
   switch (stgm.tymed)
   {
   case TYMED_GDI:
     GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
     hMemDC = CreateCompatibleDC(c->hDC);
-    SelectObject(hMemDC, stgm.u.hBitmap);
+    old_bm = SelectObject(hMemDC, stgm.u.hBitmap);
     if (has_size)
     {
       convert_sizel(c, &run->ole_obj->sizel, &sz);
@@ -5347,8 +5349,8 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
                  hMemDC, 0, 0, dibsect.dsBm.bmWidth,
                  dibsect.dsBm.bmHeight, SRCCOPY);
     }
+    SelectObject(hMemDC, old_bm);
     DeleteDC(hMemDC);
-    if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
     break;
   case TYMED_ENHMF:
     GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
@@ -5374,16 +5376,16 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
       rc.bottom = y;
       PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
     }
-    if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
     break;
   default:
     FIXME("Unsupported tymed %d\n", stgm.tymed);
     selected = FALSE;
     break;
   }
+  ReleaseStgMedium(&stgm);
+
   if (selected && !c->editor->bHideSelection)
     PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
-  IDataObject_Release(ido);
 }
 
 void ME_DeleteReObject(REOBJECT* reo)




More information about the wine-cvs mailing list