From febd611d48c064f74341b42906229bd1a57a8e39 Mon Sep 17 00:00:00 2001 From: Josh Faust Date: Wed, 27 Sep 2017 18:41:35 -0700 Subject: [PATCH] Fix glTF2::Asset::FindUniqueID() when the input string is >= 256 chars --- code/glTF2Asset.inl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index 47904b38f..264a32d4d 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -1118,11 +1118,12 @@ inline std::string Asset::FindUniqueID(const std::string& str, const char* suffi if (it == mUsedIds.end()) return id; - char buffer[256]; - int offset = ai_snprintf(buffer, sizeof(buffer), "%s_", id.c_str()); + std::vector buffer; + buffer.resize(id.size() + 16); + int offset = ai_snprintf(buffer.data(), buffer.size(), "%s_", id.c_str()); for (int i = 0; it != mUsedIds.end(); ++i) { - ai_snprintf(buffer + offset, sizeof(buffer) - offset, "%d", i); - id = buffer; + ai_snprintf(buffer.data() + offset, buffer.size() - offset, "%d", i); + id = buffer.data(); it = mUsedIds.find(id); }