uri: fix a possible NULL dereferencing
@@ -213,6 +213,8 @@ _u_parse(const char *query, const char *separator)
dbg_err_if(separator == NULL);
q = u_strdup(query);
h = hash_create3(HASHCOUNT_T_MAX, 0, 0);
+ if (!q || !h)
+ goto err;
/* foreach name=value pair... */
for (src = q; (tok = strtok_r(src, separator, &pp)) != NULL; src = NULL) {
@@ -268,6 +270,7 @@ _u_parse(const char *query, const char *separator)
err:
u_free(q);
u_free(key);
+ if (h)
hash_free(h);
return NULL;
}
