summaryrefslogtreecommitdiff
path: root/src/core/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/string.c')
-rw-r--r--src/core/string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/string.c b/src/core/string.c
index 9072d59..dd9b268 100644
--- a/src/core/string.c
+++ b/src/core/string.c
@@ -121,7 +121,7 @@ dom_exception dom_string_create(const uint8_t *ptr, size_t len,
if (ret == NULL)
return DOM_NO_MEM_ERR;
- ret->data.cdata.ptr = malloc(len);
+ ret->data.cdata.ptr = malloc((len > 0) ? len : 1);
if (ret->data.cdata.ptr == NULL) {
free(ret);
return DOM_NO_MEM_ERR;