summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2012-11-12 20:46:38 +0000
committerSimon Howard2012-11-12 20:46:38 +0000
commita854a3a5e000ad0bb78d4bb51ecc8c408dd44ec6 (patch)
tree0ff1b1346eb29dc3d520578508f1cf71f2e0e6b6
parentcab5118726def9984202599e9337b8b86111977a (diff)
downloadchocolate-doom-a854a3a5e000ad0bb78d4bb51ecc8c408dd44ec6.tar.gz
chocolate-doom-a854a3a5e000ad0bb78d4bb51ecc8c408dd44ec6.tar.bz2
chocolate-doom-a854a3a5e000ad0bb78d4bb51ecc8c408dd44ec6.zip
Fix registry handles not being closed (thanks Quasar).
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2540
-rw-r--r--src/d_iwad.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/d_iwad.c b/src/d_iwad.c
index 6d0ade26..a810f2a2 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -172,36 +172,30 @@ static char *GetRegistryString(registry_value_t *reg_val)
// Open the key (directory where the value is stored)
- if (RegOpenKeyEx(reg_val->root, reg_val->path, 0, KEY_READ, &key)
- != ERROR_SUCCESS)
+ if (RegOpenKeyEx(reg_val->root, reg_val->path,
+ 0, KEY_READ, &key) != ERROR_SUCCESS)
{
return NULL;
}
- // Find the type and length of the string
+ result = NULL;
- if (RegQueryValueEx(key, reg_val->value, NULL, &valtype, NULL, &len)
- != ERROR_SUCCESS)
- {
- return NULL;
- }
-
- // Only accept strings
+ // Find the type and length of the string, and only accept strings.
- if (valtype != REG_SZ)
+ if (RegQueryValueEx(key, reg_val->value,
+ NULL, &valtype, NULL, &len) == ERROR_SUCCESS
+ && valtype == REG_SZ)
{
- return NULL;
- }
-
- // Allocate a buffer for the value and read the value
+ // Allocate a buffer for the value and read the value
- result = malloc(len);
+ result = malloc(len);
- if (RegQueryValueEx(key, reg_val->value, NULL, &valtype, (unsigned char *) result, &len)
- != ERROR_SUCCESS)
- {
- free(result);
- return NULL;
+ if (RegQueryValueEx(key, reg_val->value, NULL, &valtype,
+ (unsigned char *) result, &len) != ERROR_SUCCESS)
+ {
+ free(result);
+ result = NULL;
+ }
}
// Close the key
@@ -299,6 +293,8 @@ static void CheckSteamEdition(void)
AddIWADDir(subpath);
}
+
+ free(install_path);
}
// Default install directories for DOS Doom