diff --git a/containers/choc_Value.h b/containers/choc_Value.h index ed66604..82abf4b 100644 --- a/containers/choc_Value.h +++ b/containers/choc_Value.h @@ -2323,7 +2323,7 @@ inline std::string_view ValueView::getString() const // from this function if (stringDictionary == nullptr) throwError ("No string dictionary supplied"); - + return stringDictionary->getStringForHandle (getStringHandle()); } @@ -2430,43 +2430,41 @@ void ValueView::serialise (OutputStream& output) const if (type.isVoid()) return; - auto dataSize = type.getValueDataSize(); - check (dataSize > 0, "Invalid data size"); - - if (stringDictionary == nullptr || ! type.usesStrings()) - { - output.write (data, dataSize); - return; - } - - uint8_t* localCopy = nullptr; + auto dataSize = type.getValueDataSize(); + check (dataSize > 0, "Invalid data size"); - #if _MSC_VER + if (stringDictionary == nullptr || ! type.usesStrings()) + { + output.write (data, dataSize); + return; + } - #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wlanguage-extension-token" - #endif + uint8_t* localCopy = nullptr; - __try - { - localCopy = (uint8_t*) _alloca (dataSize); - } - __except (GetExceptionCode() == STATUS_STACK_OVERFLOW) - { - throwError ("Stack overflow"); - } + #if _MSC_VER + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wlanguage-extension-token" + #endif - #ifdef __clang__ - #pragma clang diagnostic pop - #endif + __try + { + localCopy = (uint8_t*) _alloca (dataSize); + } + __except (1) + { + throwError ("Stack overflow"); + } - #else - localCopy = (uint8_t*) alloca (dataSize); + #ifdef __clang__ + #pragma clang diagnostic pop #endif + #else + localCopy = (uint8_t*) alloca (dataSize); + #endif - check (localCopy != nullptr, "Stack allocation failed"); - std::memcpy (localCopy, data, dataSize); + check (localCopy != nullptr, "Stack allocation failed"); + std::memcpy (localCopy, data, dataSize); static constexpr uint32_t maxStrings = 128; uint32_t numStrings = 0, stringDataSize = 0;