summaryrefslogtreecommitdiff
path: root/source/core/slang-writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-writer.cpp')
-rw-r--r--source/core/slang-writer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/source/core/slang-writer.cpp b/source/core/slang-writer.cpp
index 433cc6992..a3222b0d2 100644
--- a/source/core/slang-writer.cpp
+++ b/source/core/slang-writer.cpp
@@ -28,6 +28,7 @@ SlangResult WriterHelper::print(const char* format, ...)
SlangResult res = SLANG_OK;
+ // numChars is the amount of characters needed *not* including terminating 0
size_t numChars;
{
// Create a copy of args, as will be consumed by calcFormattedSize
@@ -39,7 +40,8 @@ SlangResult WriterHelper::print(const char* format, ...)
if (numChars > 0)
{
- char* appendBuffer = m_writer->beginAppendBuffer(numChars);
+ // We need to add 1 here, because calcFormatted, *requires* space for terminating 0
+ char* appendBuffer = m_writer->beginAppendBuffer(numChars + 1);
StringUtil::calcFormatted(format, args, numChars, appendBuffer);
res = m_writer->endAppendBuffer(appendBuffer, numChars);
}