From 04e703a670e7f3d95d8c417936b58fc3e8e2e428 Mon Sep 17 00:00:00 2001
From: rogerdpack <rogerpack2005@gmail.com>
Date: Tue, 19 Aug 2014 07:42:18 -0600
Subject: [PATCH] gdigrab: fix gdi object leak if using mouse, based on patch
 from hlszl1983@163.com

Signed-off-by: rogerdpack <rogerpack2005@gmail.com>
---
 libavdevice/gdigrab.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index bccfef2..760bdb3 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -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 {
-- 
1.9.1

