From: Fabian Keil <fk@fabiankeil.de>
Date: Wed, 12 Aug 2015 10:39:16 +0000 (+0000)
Subject: WinMain: Use the correct function to close the event handle
X-Git-Tag: v_3_0_24~84
X-Git-Url: http://www.privoxy.org/gitweb/@default-cgi@/faq/%22https:/user-manual/static/@default-cgi@toggle?a=commitdiff_plain;h=cf15fe9e050f5afc72c3079f43466750f1aa67fb;p=privoxy.git

WinMain: Use the correct function to close the event handle

According to Microsoft's documentation DeleteObject() is
used to delete a "logical pen, brush, font, bitmap, region,
or palette" while CloseHandle() is supposed to be used
for the handle returned by CreateEvent():
https://msdn.microsoft.com/en-us/library/windows/desktop/dd183539%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682396%28v=vs.85%29.aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211%28v=vs.85%29.aspx

It's conceivable that this commit fixes a tiny memory leak,
but then again maybe not as DeleteObject() is apparently full
of magic:
http://blogs.msdn.com/b/oldnewthing/archive/2013/03/06/10399678.aspx

Reported by Jarry Xu in #891.
---

diff --git a/win32.c b/win32.c
index 92c69a4e..9b08eb37 100644
--- a/win32.c
+++ b/win32.c
@@ -1,4 +1,4 @@
-const char win32_rcs[] = "$Id: win32.c,v 1.18 2011/09/04 11:10:56 fabiankeil Exp $";
+const char win32_rcs[] = "$Id: win32.c,v 1.19 2012/03/09 16:23:50 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/win32.c,v $
@@ -204,7 +204,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
    g_nCmdShow = nCmdShow;
    _beginthread(UserInterfaceThread, 0, &hInitCompleteEvent);
    WaitForSingleObject(hInitCompleteEvent, INFINITE);
-   DeleteObject(hInitCompleteEvent);
+   CloseHandle(hInitCompleteEvent);
 #endif
 
 #ifdef __MINGW32__