diff options
Diffstat (limited to 'libnetdata/inlined.h')
-rw-r--r-- | libnetdata/inlined.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libnetdata/inlined.h b/libnetdata/inlined.h index 7e7d8ebede..a10448b699 100644 --- a/libnetdata/inlined.h +++ b/libnetdata/inlined.h @@ -233,21 +233,21 @@ static inline char *strncpyz(char *dst, const char *src, size_t n) { return p; } -static inline void sanitize_json_string(char *dst, char *src, size_t len) { - while (*src != '\0' && len > 1) { - if (*src == '\\' || *src == '\"' || *src < 0x1F) { - if (*src < 0x1F) { - *dst++ = '_'; - src++; - len--; - } else { - *dst++ = '\\'; - *dst++ = *src++; - len -= 2; - } - } else { +static inline void sanitize_json_string(char *dst, const char *src, size_t dst_size) { + while (*src != '\0' && dst_size > 1) { + if (*src < 0x1F) { + *dst++ = '_'; + src++; + dst_size--; + } + else if (*src == '\\' || *src == '\"') { + *dst++ = '\\'; + *dst++ = *src++; + dst_size -= 2; + } + else { *dst++ = *src++; - len--; + dst_size--; } } *dst = '\0'; |