From 3a218217f41e0aa8d8a8b95cf3865ac676106c85 Mon Sep 17 00:00:00 2001 From: James Urquhart Date: Fri, 15 May 2015 12:27:52 +0100 Subject: [PATCH] Add workaround for issue #1292 --- Engine/source/console/console.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index 81c460d79..dd25ef399 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -1759,12 +1759,32 @@ const char *ConsoleValue::getStringValue() return sval; else if (type == TypeInternalStringStackPtr) return STR.mBuffer + (uintptr_t)sval; - if(type == TypeInternalFloat) - return Con::getData(TypeF32, &fval, 0); - else if(type == TypeInternalInt) - return Con::getData(TypeS32, &ival, 0); else - return Con::getData(type, dataPtr, 0, enumTable); + { + // We need a string representation, so lets create one + const char *internalValue = NULL; + + if(type == TypeInternalFloat) + internalValue = Con::getData(TypeF32, &fval, 0); + else if(type == TypeInternalInt) + internalValue = Con::getData(TypeS32, &ival, 0); + else + internalValue = Con::getData(type, dataPtr, 0, enumTable); + + if (!internalValue) + return ""; + + U32 stringLen = dStrlen(internalValue); + U32 newLen = ((stringLen + 1) + 15) & ~15; // pad upto next cache line + + if(sval == typeValueEmpty || type == TypeInternalStackString || type == TypeInternalStringStackPtr) + sval = (char *) dMalloc(newLen); + else if(newLen > bufferLen) + sval = (char *) dRealloc(sval, newLen); + + dStrcpy(sval, internalValue); + return sval; + } } StringStackPtr ConsoleValue::getStringStackPtr()