forked from lda/telodendria
Fix some sneaky memory bugs and resource leaks.
This commit is contained in:
parent
bf65f29fdf
commit
82d460da6f
3 changed files with 21 additions and 4 deletions
|
@ -165,7 +165,9 @@ HttpServerContextFree(HttpServerContext * c)
|
||||||
HashMapFree(c->requestParams);
|
HashMapFree(c->requestParams);
|
||||||
|
|
||||||
Free(c->requestPath);
|
Free(c->requestPath);
|
||||||
|
#if 0
|
||||||
fclose(c->stream);
|
fclose(c->stream);
|
||||||
|
#endif
|
||||||
|
|
||||||
Free(c);
|
Free(c);
|
||||||
}
|
}
|
||||||
|
@ -513,7 +515,7 @@ HttpServerWorkerThread(void *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestPath[i] = '\0';
|
requestPath[i] = '\0';
|
||||||
requestParams = HttpParamDecode(requestPath + i + 1);
|
requestParams = HttpParamDecode(requestPath + i);
|
||||||
|
|
||||||
context = HttpServerContextCreate(requestMethod, requestPath, requestParams, fp);
|
context = HttpServerContextCreate(requestMethod, requestPath, requestParams, fp);
|
||||||
if (!context)
|
if (!context)
|
||||||
|
@ -596,7 +598,9 @@ bad_request:
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
Free(line);
|
Free(line);
|
||||||
|
#if 0
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -334,12 +334,13 @@ MemoryInfoGet(void *p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
pthread_mutex_unlock(&lock);
|
||||||
|
return allocations[hash];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&lock);
|
pthread_mutex_unlock(&lock);
|
||||||
return allocations[hash];
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
|
|
@ -154,7 +154,6 @@ main(int argc, char **argv)
|
||||||
memset(&matrixArgs, 0, sizeof(matrixArgs));
|
memset(&matrixArgs, 0, sizeof(matrixArgs));
|
||||||
|
|
||||||
lc = LogConfigCreate();
|
lc = LogConfigCreate();
|
||||||
LogConfigLevelSet(lc, LOG_DEBUG);
|
|
||||||
|
|
||||||
if (!lc)
|
if (!lc)
|
||||||
{
|
{
|
||||||
|
@ -212,6 +211,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
fclose(stdin);
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (unveil(configArg, "r") != 0)
|
if (unveil(configArg, "r") != 0)
|
||||||
{
|
{
|
||||||
|
@ -472,6 +472,16 @@ finish:
|
||||||
HttpServerFree(httpServer);
|
HttpServerFree(httpServer);
|
||||||
Log(lc, LOG_DEBUG, "Freed HTTP Server.");
|
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);
|
TelodendriaConfigFree(tConfig);
|
||||||
DbClose(matrixArgs.db);
|
DbClose(matrixArgs.db);
|
||||||
|
|
||||||
|
@ -483,5 +493,7 @@ finish:
|
||||||
LogConfigFree(lc);
|
LogConfigFree(lc);
|
||||||
|
|
||||||
MemoryFreeAll();
|
MemoryFreeAll();
|
||||||
|
|
||||||
|
fclose(stderr);
|
||||||
return exit;
|
return exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue