@@ -196,7 +196,7 @@ void get_hash_value(parsertype p, void *elem, unsigned char *hash)
ascii_to_hash(hash, hash_ascii);
}
-bool set_find_path(const char **nodes, const char *newpath, char **tmp)
+bool set_find_path(const char **nodes, const char *newpath, char ***tmp)
{
char **paths;
unsigned int count;
@@ -204,7 +204,6 @@ bool set_find_path(const char **nodes, const char *newpath, char **tmp)
char *token, *ref;
bool first = true;
int allocstr = 0;
- (void)tmp;
/*
* Include of files is not supported,
@@ -287,7 +286,7 @@ bool set_find_path(const char **nodes, const char *newpath, char **tmp)
}
free(ref);
- tmp = paths;
+ *tmp = paths;
return true;
}
@@ -155,7 +155,7 @@ void *find_root_libconfig(config_t *cfg, const char **nodes, unsigned int depth)
if (elem && config_setting_is_group(elem) == CONFIG_TRUE) {
ref = get_field_string_libconfig(elem, "ref");
if (ref) {
- if (!set_find_path(nodes, ref, tmp)) {
+ if (!set_find_path(nodes, ref, &tmp)) {
free(root);
return NULL;
}
@@ -201,7 +201,7 @@ void *find_root_json(json_object *root, const char **nodes, unsigned int depth)
if (type == json_type_object || type == json_type_array) {
str = get_field_string_json(node, "ref");
if (str) {
- if (!set_find_path(nodes, str, tmp))
+ if (!set_find_path(nodes, str, &tmp))
return NULL;
node = find_root_json(root, nodes, depth);
free_string_array(tmp);
@@ -98,7 +98,7 @@ void get_hash_value(parsertype p, void *elem, unsigned char *hash);
void check_field_string(const char *src, char *dst, const size_t max_len);
void *find_root(parsertype p, void *root, const char **nodes);
void *get_node(parsertype p, void *root, const char **nodes);
-bool set_find_path(const char **nodes, const char *newpath, char **tmp);
+bool set_find_path(const char **nodes, const char *newpath, char ***tmp);
#define GET_FIELD_STRING(p, e, name, d) \
get_field_string_with_size(p, e, name, d, sizeof(d))
@@ -145,7 +145,7 @@ static int parser_follow_link(parsertype p, void *cfg, void *elem,
for (int j = 0; j < count_string_array(nodes); j++) {
linknodes[j] = nodes[j];
}
- if (!set_find_path(linknodes, ref, tmp)) {
+ if (!set_find_path(linknodes, ref, &tmp)) {
free(linknodes);
return -1;
}
properly set 'tmp' through an extra indirection instead of leaking the string array Reported-by: gcc -fanalyzer Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> --- core/parsing_library.c | 5 ++--- corelib/parsing_library_libconfig.c | 2 +- corelib/parsing_library_libjson.c | 2 +- include/parselib.h | 2 +- parser/parser.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-)