Author: tml
Date: Fri Feb 15 00:29:37 2008
New Revision: 19573
URL: http://svn.gnome.org/viewvc/gtk+?rev=19573&view=rev
Log:
2008-02-15 Tor Lillqvist <[EMAIL PROTECTED]>
* gtk/gtkfilesystemwin32.c (get_viewable_logical_drives): Don't
leak Registry key handles. (#516578)
Modified:
branches/gtk-2-12/ChangeLog
branches/gtk-2-12/gtk/gtkfilesystemwin32.c
Modified: branches/gtk-2-12/gtk/gtkfilesystemwin32.c
==============================================================================
--- branches/gtk-2-12/gtk/gtkfilesystemwin32.c (original)
+++ branches/gtk-2-12/gtk/gtkfilesystemwin32.c Fri Feb 15 00:29:37 2008
@@ -346,33 +346,47 @@
get_viewable_logical_drives (void)
{
guint viewable_drives = GetLogicalDrives ();
- HKEY my_key;
+ HKEY key;
DWORD var_type = REG_DWORD; //the value's a REG_DWORD type
DWORD no_drives_size = 4;
DWORD no_drives;
gboolean hklm_present = FALSE;
- RegOpenKeyEx (HKEY_LOCAL_MACHINE,
"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", 0,
KEY_READ, &my_key);
- if (RegQueryValueEx (my_key, "NoDrives", NULL, &var_type, &no_drives,
&no_drives_size) == ERROR_SUCCESS)
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
+ "Software\\Microsoft\\Windows\\"
+ "CurrentVersion\\Policies\\Explorer",
+ 0, KEY_READ, &key) == ERROR_SUCCESS)
{
- // We need the bits that are set in viewable_drives, and unset in
no_drives.
- viewable_drives = viewable_drives & ~no_drives;
- hklm_present = TRUE;
+ if (RegQueryValueEx (key, "NoDrives", NULL, &var_type,
+ (LPBYTE) &no_drives, &no_drives_size) ==
ERROR_SUCCESS)
+ {
+ /* We need the bits that are set in viewable_drives, and
+ * unset in no_drives.
+ */
+ viewable_drives = viewable_drives & ~no_drives;
+ hklm_present = TRUE;
+ }
+ RegCloseKey (key);
}
- // If the key is present in HKLM then the one in HKCU should be ignored
+ /* If the key is present in HKLM then the one in HKCU should be ignored */
if (!hklm_present)
{
- RegOpenKeyEx (HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", 0,
KEY_READ, &my_key);
- if (RegQueryValueEx (my_key, "NoDrives", NULL, &var_type, &no_drives,
&no_drives_size) == ERROR_SUCCESS)
- {
- // We need the bits that are set in viewable_drives, and unset in
no_drives.
- viewable_drives = viewable_drives & ~no_drives;
- }
- }
+ if (RegOpenKeyEx (HKEY_CURRENT_USER,
+ "Software\\Microsoft\\Windows\\"
+ "CurrentVersion\\Policies\\Explorer",
+ 0, KEY_READ, &key) == ERROR_SUCCESS)
+ {
+ if (RegQueryValueEx (key, "NoDrives", NULL, &var_type,
+ (LPBYTE) &no_drives, &no_drives_size) ==
ERROR_SUCCESS)
+ {
+ viewable_drives = viewable_drives & ~no_drives;
+ }
+ RegCloseKey (key);
+ }
+ }
- RegCloseKey (my_key);
return viewable_drives;
}
_______________________________________________
SVN-commits-list mailing list (read only)
http://mail.gnome.org/mailman/listinfo/svn-commits-list
Want to limit the commits to a few modules? Go to above URL, log in to edit
your options and select the modules ('topics') you want.
Module maintainer? It is possible to set the reply-to to your development
mailing list. Email [EMAIL PROTECTED] if interested.