]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
windows mod_enum fix potential seg
authorJeff Lenk <jeff@jefflenk.com>
Thu, 31 Mar 2011 02:09:48 +0000 (21:09 -0500)
committerJeff Lenk <jeff@jefflenk.com>
Thu, 31 Mar 2011 02:10:24 +0000 (21:10 -0500)
src/mod/applications/mod_enum/mod_enum.c

index 0e70e8267c4ed9241dfa88f4ac8ebb96a2832a2c..b8b380a66e1f7c897a415e3617054e6feefa7ebd 100644 (file)
@@ -153,20 +153,20 @@ static switch_status_t load_config(void)
                        "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 
                        0, KEY_QUERY_VALUE, &hKey);
 
-               RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, NULL, &data_sz);
-               if (globals.server) {
-                       free(globals.server);
-               }
-               buf = (char*)malloc(data_sz + 1);
-
-               RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, (LPBYTE)buf, &data_sz);
+               if (hKey) {
+                       RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, NULL, &data_sz);
+                       if (data_sz) {
+                               buf = (char*)malloc(data_sz + 1);
 
-               RegCloseKey(hKey);
+                               RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, (LPBYTE)buf, &data_sz);
+                               RegCloseKey(hKey);
 
-               if(buf[data_sz - 1] != 0) {
-                       buf[data_sz] = 0;
+                               if(buf[data_sz - 1] != 0) {
+                                       buf[data_sz] = 0;
+                               }
+                               globals.server = buf;
+                       }
                }
-               globals.server = buf;
        }
 #endif