correctly handle empty list of replication servers

This commit is contained in:
jmjatlanta 2017-07-31 08:50:20 -05:00
parent d969f48324
commit 9bceade4d8

View file

@ -481,10 +481,7 @@ int fs_repo_open_config(struct FSRepo* repo) {
// nodes list
int nodes_pos = _find_token(data, tokens, num_tokens, curr_pos, "Nodes");
if (nodes_pos >= 0) {
if (tokens[nodes_pos].type != JSMN_ARRAY) {
free(data);
return 0;
}
if (tokens[nodes_pos].type == JSMN_ARRAY) {
int nodes_size = tokens[nodes_pos].size;
repo->config->replication->nodes = libp2p_utils_vector_new(nodes_size);
nodes_pos++;
@ -500,6 +497,7 @@ int fs_repo_open_config(struct FSRepo* repo) {
}
}
}
}
// free the memory used reading the json file
free(data);
free(priv_key_base64);