From 0ae66d27039481dc2a507bbc8482f691037c1a5a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 8 Apr 2025 13:14:10 +0200 Subject: [PATCH] Fix set (#6073) * Fix set * Fix: Fix implicite cast from size_t to uint32_t --- include/assimp/types.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index 920f7fa7a..f2da91d4f 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -303,12 +303,21 @@ struct aiString { } /** Copy a const char* to the aiString */ - void Set(const char *sz) { - ai_int32 len = (ai_uint32)::strlen(sz); - if (len > static_cast(AI_MAXLEN - 1)) { - len = static_cast(AI_MAXLEN - 1); + void Set(const char *sz, size_t maxlen) { + if (sz == nullptr) { + return; } - length = len; + size_t len = 0; + for (size_t i=0; i AI_MAXLEN - 1) { + len = AI_MAXLEN - 1; + } + length = static_cast(len); memcpy(data, sz, len); data[len] = 0; }