Improve robustness

This commit is contained in:
Přemysl Eric Janouch 2017-05-18 19:45:56 +02:00
parent c47581a922
commit 3ecceb8902
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 3 additions and 3 deletions

6
ell.c
View File

@ -151,9 +151,9 @@ item_free_list (struct item *item) {
static struct item *
new_clone (const struct item *item) {
size_t size = sizeof *item;
size_t size = sizeof *item + 1;
if (item->type == ITEM_STRING)
size += item->len + 1;
size += item->len;
struct item *clone = malloc (size);
if (!clone)
@ -202,7 +202,7 @@ new_string (const char *s, ssize_t len) {
static struct item *
new_list (struct item *head) {
struct item *item = calloc (1, sizeof *item);
struct item *item = calloc (1, sizeof *item + 1);
if (!item)
return NULL;