windows mod_enum fix potential seg

This commit is contained in:
Jeff Lenk 2011-03-30 21:09:48 -05:00
parent 31580d6661
commit 4e3d1f3f86

View 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);
if (hKey) {
RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, NULL, &data_sz);
if (data_sz) {
buf = (char*)malloc(data_sz + 1);
RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, (LPBYTE)buf, &data_sz);
RegCloseKey(hKey);
if(buf[data_sz - 1] != 0) {
buf[data_sz] = 0;
}
globals.server = buf;
}
}
buf = (char*)malloc(data_sz + 1);
RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, (LPBYTE)buf, &data_sz);
RegCloseKey(hKey);
if(buf[data_sz - 1] != 0) {
buf[data_sz] = 0;
}
globals.server = buf;
}
#endif