lpereira / lwan

Experimental, scalable, high performance HTTP server

Home Page:https://lwan.ws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leaks in lwan

ryancaicse opened this issue · comments

The memory block created at Line 125 is leaked in the method parse_listener_prefix.

lwan/src/lib/lwan.c

Lines 125 to 139 in 2f34d6f

struct lwan_url_map *copy = malloc(sizeof(*copy));
if (!copy)
lwan_status_critical_perror("Could not copy URL map");
memcpy(copy, map, sizeof(*copy));
copy->prefix = strdup(prefix ? prefix : copy->prefix);
if (!copy->prefix)
lwan_status_critical_perror("Could not copy URL prefix");
copy->prefix_len = strlen(copy->prefix);
lwan_trie_add(t, copy->prefix, copy);
return copy;

lwan/src/lib/lwan.c

Lines 400 to 404 in 2f34d6f

add_url_map(&lwan->url_map_trie, prefix, &url_map);
out:
hash_free(hash);
config_close(isolated);

@lpereira Sorry, when I take a close look, it seems it's wrong.