Index: src/3rdparty/squirrel/squirrel/sqapi.cpp
===================================================================
--- src/3rdparty/squirrel/squirrel/sqapi.cpp (revision 27218)
+++ src/3rdparty/squirrel/squirrel/sqapi.cpp (working copy)
@@ -1262,9 +1262,17 @@
WChar buf_lexfeed(SQUserPointer file)
{
BufState *buf=(BufState*)file;
- if(buf->size<(buf->ptr+1))
- return 0;
- return buf->buf[buf->ptr++];
+
+ if (buf->size < buf->ptr + 1) return 0;
+
+ int len = Utf8EncodedCharLen(buf->buf[buf->ptr]);
+ if (buf->size < buf->ptr + len) return 0;
+
+ WChar result;
+ Utf8Decode(&result, buf->buf + buf->ptr);
+ buf->ptr += len;
+
+ return result;
}
SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror) {