From 0e3b383c4bf7a9644e0c914814ba38aacc32fa59 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 12 Feb 2013 15:50:37 -0800 Subject: [PATCH] Handle partial characters at the end of the read buffer when loading Lua scripts. Closes #1576. --- aegisub/src/auto4_lua_scriptreader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aegisub/src/auto4_lua_scriptreader.cpp b/aegisub/src/auto4_lua_scriptreader.cpp index e7fcf0b38..3206df6fe 100644 --- a/aegisub/src/auto4_lua_scriptreader.cpp +++ b/aegisub/src/auto4_lua_scriptreader.cpp @@ -50,6 +50,8 @@ namespace Automation4 { size_t out_bytes = sizeof(buf); conv->Convert(&in, &in_bytes, &out, &out_bytes); + if (in_bytes > 0 && in != in_buf) + file.seekg(-(std::streamoff)in_bytes, std::ios_base::cur); *bytes_read = out - buf; // Skip the bom