summaryrefslogtreecommitdiff
path: root/src/chunk.h
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2015-06-07 17:44:11 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2015-06-07 21:42:15 +0200
commit0641c5e4e9727ddde0d2be1aebe3fd7009d010f5 (patch)
treeb3f9402e18ef67eb17a61f949f524b9a3cbda54a /src/chunk.h
parent54abb08e615ab4d094b37ce3102df81779ee2c7a (diff)
Helper to safely call strlen
Diffstat (limited to 'src/chunk.h')
-rw-r--r--src/chunk.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/chunk.h b/src/chunk.h
index 364918d..f23a02d 100644
--- a/src/chunk.h
+++ b/src/chunk.h
@@ -87,7 +87,7 @@ static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str)
c->data = NULL;
c->alloc = 0;
} else {
- c->len = strlen(str);
+ c->len = cmark_strbuf_safe_strlen(str);
c->data = (unsigned char *)malloc(c->len + 1);
c->alloc = 1;
memcpy(c->data, str, c->len + 1);
@@ -96,7 +96,8 @@ static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str)
static inline cmark_chunk cmark_chunk_literal(const char *data)
{
- cmark_chunk c = {(unsigned char *)data, data ? strlen(data) : 0, 0};
+ bufsize_t len = data ? cmark_strbuf_safe_strlen(data) : 0;
+ cmark_chunk c = {(unsigned char *)data, len, 0};
return c;
}