aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-18 19:45:56 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-21 13:19:45 +0200
commit3ecceb89025ac3307909eec6e5a0b81d60a01547 (patch)
tree9d339258aa2c74133de1529ba14c7953b60abd84
parentc47581a922b637bda2a5955508020eab3f9c43ca (diff)
downloadell-3ecceb89025ac3307909eec6e5a0b81d60a01547.tar.gz
ell-3ecceb89025ac3307909eec6e5a0b81d60a01547.tar.xz
ell-3ecceb89025ac3307909eec6e5a0b81d60a01547.zip
Improve robustness
-rwxr-xr-xell.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ell.c b/ell.c
index cb30ebf..4cb09e1 100755
--- a/ell.c
+++ b/ell.c
@@ -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;