forked from lda/telodendria
Fix some sneaky memory bugs and resource leaks.
This commit is contained in:
parent
bf65f29fdf
commit
82d460da6f
|
@ -165,7 +165,9 @@ HttpServerContextFree(HttpServerContext * c)
|
|||
HashMapFree(c->requestParams);
|
||||
|
||||
Free(c->requestPath);
|
||||
#if 0
|
||||
fclose(c->stream);
|
||||
#endif
|
||||
|
||||
Free(c);
|
||||
}
|
||||
|
@ -513,7 +515,7 @@ HttpServerWorkerThread(void *args)
|
|||
}
|
||||
|
||||
requestPath[i] = '\0';
|
||||
requestParams = HttpParamDecode(requestPath + i + 1);
|
||||
requestParams = HttpParamDecode(requestPath + i);
|
||||
|
||||
context = HttpServerContextCreate(requestMethod, requestPath, requestParams, fp);
|
||||
if (!context)
|
||||
|
@ -596,7 +598,9 @@ bad_request:
|
|||
|
||||
finish:
|
||||
Free(line);
|
||||
#if 0
|
||||
fclose(fp);
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -334,12 +334,13 @@ MemoryInfoGet(void *p)
|
|||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
pthread_mutex_unlock(&lock);
|
||||
return allocations[hash];
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&lock);
|
||||
return allocations[hash];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t
|
||||
|
|
|
@ -154,7 +154,6 @@ main(int argc, char **argv)
|
|||
memset(&matrixArgs, 0, sizeof(matrixArgs));
|
||||
|
||||
lc = LogConfigCreate();
|
||||
LogConfigLevelSet(lc, LOG_DEBUG);
|
||||
|
||||
if (!lc)
|
||||
{
|
||||
|
@ -212,6 +211,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
fclose(stdin);
|
||||
#ifdef __OpenBSD__
|
||||
if (unveil(configArg, "r") != 0)
|
||||
{
|
||||
|
@ -472,6 +472,16 @@ finish:
|
|||
HttpServerFree(httpServer);
|
||||
Log(lc, LOG_DEBUG, "Freed HTTP Server.");
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're not logging to standard output, then we can close it. Otherwise,
|
||||
* if we are logging to stdout, LogConfigFree() will close it for us.
|
||||
*/
|
||||
if (!(tConfig->flags & TELODENDRIA_LOG_STDOUT))
|
||||
{
|
||||
fclose(stdout);
|
||||
}
|
||||
|
||||
TelodendriaConfigFree(tConfig);
|
||||
DbClose(matrixArgs.db);
|
||||
|
||||
|
@ -483,5 +493,7 @@ finish:
|
|||
LogConfigFree(lc);
|
||||
|
||||
MemoryFreeAll();
|
||||
|
||||
fclose(stderr);
|
||||
return exit;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue