summaryrefslogtreecommitdiff
path: root/src/chunk.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/chunk.h')
-rw-r--r--src/chunk.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/chunk.h b/src/chunk.h
index f37a2f3..015bbf9 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -59,10 +59,11 @@ static inline unsigned char *chunk_to_cstr(chunk *c)
{
unsigned char *str;
- str = malloc(c->len + 1);
- memcpy(str, c->data, c->len);
- str[c->len] = 0;
-
+ str = calloc(c->len + 1, sizeof(*str));
+ if(str != NULL) {
+ memcpy(str, c->data, c->len);
+ str[c->len] = 0;
+ }
return str;
}