diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 3860105dd..148f00637 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -239,7 +239,7 @@ void FScanner::PrepareScript () { // If the last character in the buffer is a null character, change // it to a newline. Otherwise, append a newline to the end. - if (ScriptBuffer[ScriptBuffer.Len() - 1] == '\0') + if (ScriptBuffer.Len() > 0 && ScriptBuffer[ScriptBuffer.Len() - 1] == '\0') { ScriptBuffer.LockBuffer()[ScriptBuffer.Len() - 1] = '\n'; ScriptBuffer.UnlockBuffer();