From: Jeff Lenk Date: Thu, 31 Mar 2011 02:09:48 +0000 (-0500) Subject: windows mod_enum fix potential seg X-Git-Tag: v1.2-rc1~120^2~5^2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e3d1f3f86dabc468aaa3ef3d628b49375e7aee4;p=thirdparty%2Ffreeswitch.git windows mod_enum fix potential seg --- diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index 0e70e8267c..b8b380a66e 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -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