summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Ooms <jeroenooms@gmail.com>2015-05-30 13:42:23 +0200
committerJeroen Ooms <jeroenooms@gmail.com>2015-05-30 13:42:23 +0200
commite10aa8549aa6a48af847c1768705ab869c6fcdb6 (patch)
tree41ea2130f22f4206785397758df1a5575d79cbd1
parente5d216b9190bb0ca6f33e175931630e7aa9bd430 (diff)
Fix for UBSAN note
-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;