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:
Markus Mäkelä 2017-08-04 14:51:46 +03:00
parent db531fb2e2
commit cb066fd09a
2 changed files with 3 additions and 1 deletions

View File

@ -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;

View File

@ -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)