summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-05-31 13:35:39 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2015-05-31 13:35:39 +0200
commit32d19737621ac43435ef0c39424b541e867ab642 (patch)
treec39b4e1ed4190a38c5fa8364188fa6b4a28aeb76 /src
parent9dd842c540146839688bca33bfd386b925efff2c (diff)
parente10aa8549aa6a48af847c1768705ab869c6fcdb6 (diff)
Merge pull request #49 from jeroenooms/master
Fix for UBSAN note
Diffstat (limited to 'src')
-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;