summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/chunk.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/chunk.h b/src/chunk.h
index 3d6743c..4bb4980 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -66,7 +66,9 @@ static inline const char *cmark_chunk_to_cstr(cmark_chunk *c)
}
str = (unsigned char *)malloc(c->len + 1);
if(str != NULL) {
- memcpy(str, c->data, c->len);
+ if(c->len > 0){
+ memcpy(str, c->data, c->len);
+ }
str[c->len] = 0;
}
c->data = str;