Fix some memory bugs.

This commit is contained in:
Jordan Bancino 2022-12-14 18:19:20 +00:00
parent 5880cf3ea0
commit e37e6f1bb8
3 changed files with 16 additions and 5 deletions

View File

@ -38,12 +38,18 @@ homeserver changes and fixes:
.Bl -bullet
.It
Fixed a memory leak that would occur when parsing an invalid
JSON object failed.
JSON object.
.It
Fixed an edge case where HTTP response headers were being
sent before they were set properly, causing the server to
report a status of 200 even when that wasn't the desired
status.
.It
Fixed a few memory leaks in the HTTP parameter decoder that
would occur in some edge cases.
.It
Fixed an "off-by-one" error in the HTTP server that
prevented GET parameters from being parsed.
.El
.Pp
Other changes and fixes included in this release:

View File

@ -440,7 +440,7 @@ HttpParamDecode(char *in)
if (!decKey)
{
/* Decoding error */
Free(params);
HashMapFree(params);
return NULL;
}
@ -471,11 +471,16 @@ HttpParamDecode(char *in)
if (!decVal)
{
/* Decoding error */
Free(params);
HashMapFree(params);
return NULL;
}
HashMapSet(params, decKey, decVal);
buf = HashMapSet(params, decKey, decVal);
if (buf)
{
Free(buf);
Free(decKey);
}
if (*in == '&')
{

View File

@ -561,7 +561,7 @@ HttpServerWorkerThread(void *args)
}
requestPath[i] = '\0';
requestParams = HttpParamDecode(requestPath + i);
requestParams = HttpParamDecode(requestPath + i + 1);
context = HttpServerContextCreate(requestMethod, requestPath, requestParams, fp);
if (!context)