fix possible mem leak when parsing embms cmd line input

master
Andre Puschmann 6 years ago
parent 4655ad92fe
commit 15953d011e

@ -482,22 +482,22 @@ void *input_loop(void *m) {
else if (0 == key.compare("mbms")) { else if (0 == key.compare("mbms")) {
show_mbms = true; show_mbms = true;
} else if (key.find("mbms_service_start") != string::npos) { } else if (key.find("mbms_service_start") != string::npos) {
char *dup = strdup(key.c_str()); char *dup = strdup(key.c_str());
strtok(dup, " "); strtok(dup, " ");
char *s = strtok(NULL, " "); char *s = strtok(NULL, " ");
char* p = strtok(NULL, " ");
if(NULL == s) { if(NULL == s) {
cout << "Usage: mbms_service_start <service_id> <port_number>" << endl; cout << "Usage: mbms_service_start <service_id> <port_number>" << endl;
continue; goto free_mem;
} }
serv = atoi(s); serv = atoi(s);
char* p = strtok(NULL, " ");
if(NULL == p) { if(NULL == p) {
cout << "Usage: mbms_service_start <service_id> <port_number>" << endl; cout << "Usage: mbms_service_start <service_id> <port_number>" << endl;
continue; goto free_mem;
} }
port = atoi(p); port = atoi(p);
mbms_service_start = true; mbms_service_start = true;
free_mem:
free(dup); free(dup);
} }
} }

Loading…
Cancel
Save