- Commit
- 32d19737621ac43435ef0c39424b541e867ab642
- Parent
- 9dd842c540146839688bca33bfd386b925efff2c
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Merge pull request #49 from jeroenooms/master
Fix for UBSAN note
My personal build of CMark ✏️
Merge pull request #49 from jeroenooms/master
Fix for UBSAN note
1 file changed, 3 insertions, 1 deletion
Status | File Name | N° Changes | Insertions | Deletions |
Modified | src/chunk.h | 4 | 3 | 1 |
diff --git 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;