gdigrab: fix gdi object leak if using mouse
authorrogerdpack <rogerpack2005@gmail.com>
Tue, 19 Aug 2014 13:42:18 +0000 (07:42 -0600)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 19 Aug 2014 14:07:28 +0000 (16:07 +0200)
based on patch from hlszl1983@163.com

Signed-off-by: rogerdpack <rogerpack2005@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavdevice/gdigrab.c

index bccfef2..9a185d4 100644 (file)
@@ -440,6 +440,8 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab)
         POINT pos;
         RECT clip_rect = gdigrab->clip_rect;
         HWND hwnd = gdigrab->hwnd;
+        info.hbmMask = NULL;
+        info.hbmColor = NULL;
 
         if (ci.flags != CURSOR_SHOWING)
             return;
@@ -481,6 +483,10 @@ static void paint_mouse_pointer(AVFormatContext *s1, struct gdigrab *gdigrab)
         }
 
 icon_error:
+        if (info.hbmMask)
+            DeleteObject(info.hbmMask);
+        if (info.hbmColor)
+            DeleteObject(info.hbmColor);
         if (icon)
             DestroyCursor(icon);
     } else {