浏览代码

Correct a mistake of saving a pointer position inside scratchpad that just before it is reallocated, when the memory returned is not the same it was writing to invalid address.

mingodad 13 年之前
父节点
当前提交
a9e45c1c7a
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      sqstdlib/sqstdstring.cpp

+ 2 - 2
sqstdlib/sqstdstring.cpp

@@ -123,12 +123,12 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
                         ts2++;
                         ts2++;
                       }
                       }
 
 
-                      ts2 = &dest[i];
+                      size = i; //save th i position
                       i += addlen;
                       i += addlen;
                       addlen = addlen*sizeof(SQChar);
                       addlen = addlen*sizeof(SQChar);
                       allocated += addlen + sizeof(SQChar);
                       allocated += addlen + sizeof(SQChar);
                       dest = sq_getscratchpad(v,allocated);
                       dest = sq_getscratchpad(v,allocated);
-
+                      ts2 = &dest[size]; //use saved i position
                       size = sq_getsize(v,nparam);
                       size = sq_getsize(v,nparam);
 
 
                       *ts2++ = '"';
                       *ts2++ = '"';