Fix potential segmentation fault (SIGSEGV) error #209 (#210)

This commit is contained in:
Adela0602
2019-08-04 21:11:30 +08:00
committed by Shuanglei Tao
parent a6b4d282da
commit 87a705223f

View File

@@ -382,6 +382,10 @@ main(int argc, char **argv) {
return -1;
}
char *value = strsep(&option, "=");
if (value == NULL) {
fprintf(stderr, "ttyd: invalid client option: %s, format: key=value\n", optarg);
return -1;
}
free(option);
struct json_object *obj = json_tokener_parse(value);
json_object_object_add(client_prefs, key, obj != NULL ? obj : json_object_new_string(value));