Fix memory leaks in REST API
The call to MHD_basic_auth_get_username_password allocates memory for both the password and the username. mxs_json_add_relation leaked a reference to a JSON object by using json_array_append instead of json_array_append_new.
This commit is contained in:
parent
db531fb2e2
commit
cb066fd09a
@ -187,6 +187,8 @@ bool do_auth(MHD_Connection *connection, const char* url)
|
||||
MXS_INFO("Accept authentication from '%s', %s. Request: %s", user ? user : "",
|
||||
pw ? "using password" : "no password", url);
|
||||
}
|
||||
MXS_FREE(user);
|
||||
MXS_FREE(pw);
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
@ -59,7 +59,7 @@ void mxs_json_add_relation(json_t* rel, const char* id, const char* type)
|
||||
json_t* obj = json_object();
|
||||
json_object_set_new(obj, CN_ID, json_string(id));
|
||||
json_object_set_new(obj, CN_TYPE, json_string(type));
|
||||
json_array_append(data, obj);
|
||||
json_array_append_new(data, obj);
|
||||
}
|
||||
|
||||
static string grab_next_component(string* s)
|
||||
|
Loading…
x
Reference in New Issue
Block a user