From b63c3e9be81d02e4ae56c4f963fd778df8de12de Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Fri, 23 May 2014 17:19:28 -0400 Subject: [PATCH] Fixed avformat returning the wrong length. --- Jupiter/CString_Imp.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Jupiter/CString_Imp.h b/Jupiter/CString_Imp.h index 6a3e2df..31aaa87 100644 --- a/Jupiter/CString_Imp.h +++ b/Jupiter/CString_Imp.h @@ -482,10 +482,11 @@ template<> size_t inline Jupiter::CString_Strict::avformat(const char *for Jupiter::CString_Type::base = t; Jupiter::CString_Type::curr = Jupiter::CString_Type::base; - vsnprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, minLen, format, args); + minLen = vsnprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, minLen, format, args); + if (minLen <= 0) return 0; Jupiter::CString_Type::strLen += minLen; Jupiter::CString_Type::curr[Jupiter::CString_Type::strLen] = 0; - return Jupiter::CString_Type::strLen; + return minLen; } template<> size_t inline Jupiter::CString_Strict::avformat(const wchar_t *format, va_list args) @@ -503,10 +504,11 @@ template<> size_t inline Jupiter::CString_Strict::avformat(const wchar_ Jupiter::CString_Type::base = t; Jupiter::CString_Type::curr = Jupiter::CString_Type::base; - vswprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, minLen, format, args); + minLen = vswprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, minLen, format, args); + if (minLen <= 0) return 0; Jupiter::CString_Type::strLen += minLen; Jupiter::CString_Type::curr[Jupiter::CString_Type::strLen] = 0; - return Jupiter::CString_Type::strLen; + return minLen; } template size_t Jupiter::CString_Strict::avformat(const T *format, va_list args) @@ -896,10 +898,11 @@ template<> size_t inline Jupiter::CString_Loose::avformat(const char *form Jupiter::strcpy(Jupiter::CString_Type::base, Jupiter::CString_Type::curr); Jupiter::CString_Type::curr = Jupiter::CString_Type::base; } - vsnprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, Jupiter::CString_Loose::strSize - Jupiter::CString_Type::strLen, format, args); - Jupiter::CString_Type::strLen = minLen; + minLen = vsnprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, Jupiter::CString_Loose::strSize - Jupiter::CString_Type::strLen, format, args); + if (minLen <= 0) return 0; + Jupiter::CString_Type::strLen += minLen; Jupiter::CString_Type::curr[Jupiter::CString_Type::strLen] = 0; - return Jupiter::CString_Type::strLen; + return minLen; } template<> size_t inline Jupiter::CString_Loose::avformat(const wchar_t *format, va_list args) @@ -925,10 +928,11 @@ template<> size_t inline Jupiter::CString_Loose::avformat(const wchar_t Jupiter::strcpy(Jupiter::CString_Type::base, Jupiter::CString_Type::curr); Jupiter::CString_Type::curr = Jupiter::CString_Type::base; } - vswprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, Jupiter::CString_Loose::strSize - Jupiter::CString_Type::strLen, format, args); - Jupiter::CString_Type::strLen = minLen; + minLen = vswprintf(Jupiter::CString_Type::curr + Jupiter::CString_Type::strLen, Jupiter::CString_Loose::strSize - Jupiter::CString_Type::strLen, format, args); + if (minLen <= 0) return 0; + Jupiter::CString_Type::strLen += minLen; Jupiter::CString_Type::curr[Jupiter::CString_Type::strLen] = 0; - return Jupiter::CString_Type::strLen; + return minLen; } template size_t Jupiter::CString_Loose::avformat(const T *format, va_list args)