1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

fixed memory leak

git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@63 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
cameronrich
2007-02-18 08:14:01 +00:00
parent 61fd249441
commit 900b0eb96e
12 changed files with 100 additions and 84 deletions

View File

@ -53,8 +53,6 @@ static void sigint_cleanup(int sig)
{
struct serverstruct *sp;
struct connstruct *tp;
int i;
while (servers != NULL)
{
@ -66,16 +64,20 @@ static void sigint_cleanup(int sig)
servers = sp;
}
for (i = 0; i < INITIAL_CONNECTION_SLOTS; i++)
while (freeconns != NULL)
{
if (freeconns == NULL)
break;
tp = freeconns->next;
free(freeconns);
freeconns = tp;
}
while (usedconns != NULL)
{
tp = usedconns->next;
free(usedconns);
usedconns = tp;
}
#if defined(CONFIG_HTTP_HAS_CGI)
while (cgiexts)
{
@ -129,20 +131,6 @@ int main(int argc, char *argv[])
freeconns->next = tp;
}
/* change to webroot for better security */
if (chroot(webroot))
{
#ifdef CONFIG_HTTP_VERBOSE
fprintf(stderr, "'%s' is not a directory\n", webroot);
#endif
exit(1);
}
#ifndef WIN32
setgid(32767);
setuid(32767);
#endif
if ((active = openlistener(CONFIG_HTTP_PORT)) == -1)
{
#ifdef CONFIG_HTTP_VERBOSE
@ -179,6 +167,21 @@ int main(int argc, char *argv[])
ssl_version(), CONFIG_HTTP_PORT, CONFIG_HTTP_HTTPS_PORT);
TTY_FLUSH();
#endif
/* change to webroot for better security */
if (chroot(webroot))
{
#ifdef CONFIG_HTTP_VERBOSE
fprintf(stderr, "'%s' is not a directory\n", webroot);
#endif
exit(1);
}
#ifndef WIN32
setgid(32767);
setuid(32767);
#endif
#if defined(CONFIG_HTTP_IS_DAEMON)
if (fork() > 0) /* parent will die */
exit(0);
@ -560,7 +563,7 @@ static void addconnection(int sd, char *ip, int is_ssl)
/* Get ourselves a connstruct */
if (freeconns == NULL)
tp = (struct connstruct *)malloc(sizeof(struct connstruct));
tp = (struct connstruct *)calloc(1, sizeof(struct connstruct));
else
{
tp = freeconns;