fix compiler warning in secure mode

This commit is contained in:
daan 2020-04-20 18:04:09 -07:00
parent 3484cda169
commit e31298bdc3

View File

@ -650,7 +650,7 @@ mi_decl_restrict char* mi_strdup(const char* s) mi_attr_noexcept {
mi_decl_restrict char* mi_heap_strndup(mi_heap_t* heap, const char* s, size_t n) mi_attr_noexcept {
if (s == NULL) return NULL;
const char* end = (const char*)memchr(s, 0, n); // find end of string in the first `n` characters (returns NULL if not found)
const size_t m = (end != NULL ? (end - s) : n); // `m` is the minimum of `n` or the end-of-string
const size_t m = (end != NULL ? (size_t)(end - s) : n); // `m` is the minimum of `n` or the end-of-string
mi_assert_internal(m <= n);
char* t = (char*)mi_heap_malloc(heap, m+1);
if (t == NULL) return NULL;