mirror of
https://github.com/lxsang/ant-http
synced 2024-11-17 17:08:20 +01:00
fix memory leak bug
This commit is contained in:
parent
5f12b8917a
commit
4679f6ab04
@ -19,8 +19,13 @@ void accept_request(void* client)
|
||||
//char *query_string = NULL;
|
||||
//LOG("SOCK IS %d\n", ((antd_client_t*)client)->sock);
|
||||
numchars = read_buf(client, buf, sizeof(buf));
|
||||
if(numchars < 0)
|
||||
{
|
||||
unknow(client);
|
||||
goto end;
|
||||
}
|
||||
i = 0; j = 0;
|
||||
while (!ISspace(buf[j]) && (i < sizeof(method) - 1))
|
||||
while (j < numchars && !ISspace(buf[j]) && (i < sizeof(method) - 1))
|
||||
{
|
||||
method[i] = buf[j];
|
||||
i++; j++;
|
||||
@ -108,7 +113,9 @@ void accept_request(void* client)
|
||||
char* mime_type = mime(path);
|
||||
if(strcmp(mime_type,"application/octet-stream") == 0)
|
||||
{
|
||||
char* h = dvalue(server_config.handlers,ext(path));
|
||||
char * ex = ext(path);
|
||||
char* h = dvalue(server_config.handlers,ex);
|
||||
if(ex) free(ex);
|
||||
if(h)
|
||||
{
|
||||
sprintf(buf,"/%s%s",h,url);
|
||||
|
@ -81,11 +81,11 @@ char* __s(const char* fstring,...)
|
||||
*/
|
||||
void trim(char* str, const char delim)
|
||||
{
|
||||
if(!str) return;
|
||||
if(!str || strlen(str) == 0) return;
|
||||
char * p = str;
|
||||
int l = strlen(p);
|
||||
|
||||
while(p[l - 1] == delim) p[--l] = 0;
|
||||
while(l > 0 && p[l - 1] == delim)
|
||||
p[--l] = 0;
|
||||
while(* p && (* p) == delim ) ++p, --l;
|
||||
memmove(str, p, l + 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user