forked from lda/telodendria
[FIX] Fix memory issue mentionned in #33.
This commit is contained in:
parent
3ecbef27af
commit
c626b2f4f2
1 changed files with 10 additions and 6 deletions
|
@ -52,6 +52,8 @@ ROUTE_IMPL(RouteUserDirectory, path, argp)
|
||||||
char *searchTerm = NULL;
|
char *searchTerm = NULL;
|
||||||
char *requesterName = NULL;
|
char *requesterName = NULL;
|
||||||
|
|
||||||
|
char *error;
|
||||||
|
|
||||||
size_t limit = 10;
|
size_t limit = 10;
|
||||||
|
|
||||||
size_t i, included;
|
size_t i, included;
|
||||||
|
@ -62,7 +64,7 @@ ROUTE_IMPL(RouteUserDirectory, path, argp)
|
||||||
if (HttpRequestMethodGet(args->context) != HTTP_POST)
|
if (HttpRequestMethodGet(args->context) != HTTP_POST)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
response = MatrixErrorCreate(M_UNRECOGNIZED);
|
response = MatrixErrorCreate(M_UNRECOGNIZED, NULL);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +72,7 @@ ROUTE_IMPL(RouteUserDirectory, path, argp)
|
||||||
if (!request)
|
if (!request)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
response = MatrixErrorCreate(M_NOT_JSON);
|
response = MatrixErrorCreate(M_NOT_JSON, NULL);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +87,7 @@ ROUTE_IMPL(RouteUserDirectory, path, argp)
|
||||||
if (!user)
|
if (!user)
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
response = MatrixErrorCreate(M_UNKNOWN_TOKEN);
|
response = MatrixErrorCreate(M_UNKNOWN_TOKEN, NULL);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
requesterName = UserGetName(user);
|
requesterName = UserGetName(user);
|
||||||
|
@ -96,7 +98,8 @@ ROUTE_IMPL(RouteUserDirectory, path, argp)
|
||||||
{
|
{
|
||||||
/* The Spec requires search_term to be set to a string. */
|
/* The Spec requires search_term to be set to a string. */
|
||||||
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
HttpResponseStatus(args->context, HTTP_BAD_REQUEST);
|
||||||
response = MatrixErrorCreate(M_BAD_JSON);
|
error = "search_term is not a string, or is non-existent";
|
||||||
|
response = MatrixErrorCreate(M_BAD_JSON, error);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
searchTerm = StrLower(JsonValueAsString(val));
|
searchTerm = StrLower(JsonValueAsString(val));
|
||||||
|
@ -120,9 +123,10 @@ ROUTE_IMPL(RouteUserDirectory, path, argp)
|
||||||
config = ConfigLock(db);
|
config = ConfigLock(db);
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
Log(LOG_ERR, "Directory endpoint failed to lock configuration.");
|
error = "Directory endpoint failed to lock configuration.";
|
||||||
|
Log(LOG_ERR, error);
|
||||||
HttpResponseStatus(args->context, HTTP_INTERNAL_SERVER_ERROR);
|
HttpResponseStatus(args->context, HTTP_INTERNAL_SERVER_ERROR);
|
||||||
response = MatrixErrorCreate(M_UNKNOWN);
|
response = MatrixErrorCreate(M_UNKNOWN, error);
|
||||||
|
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue