Fixed memory leak in ''.indexOf('.')

This commit is contained in:
Gordon Williams 2014-06-20 08:25:46 +01:00
parent 7b9195b3bf
commit 312cb7f3a6
3 changed files with 14 additions and 1 deletions

View File

@ -32,6 +32,7 @@
Fixed parsing of multiple shifts
setWatch now reports the pin back (fix #275)
Fixed memory leak in g.getPixel with arraybuffers
Fixed memory leak in "".indexOf(".")
1v64 : Fix 'a=[2,3,4];delete a[1];'
Make sure parseInt("0x01",16)==1 and parseInt("0x01")==1 but parseInt("0b01",16)==0

View File

@ -118,7 +118,10 @@ int jswrap_string_indexOf(JsVar *parent, JsVar *substring, JsVar *fromIndex, boo
if (!substring) return 0; // out of memory
int parentLength = (int)jsvGetStringLength(parent);
int subStringLength = (int)jsvGetStringLength(substring);
if (subStringLength > parentLength) return -1;
if (subStringLength > parentLength) {
jsvUnLock(substring);
return -1;
}
int lastPossibleSearch = parentLength - subStringLength;
int idx, dir, end;
if (!lastIndexOf) { // normal indexOf

View File

@ -0,0 +1,9 @@
// test for memory leak that used to happen
var i=0,b=0,lost=0;
b = process.memory().usage;
for (i=0;i<10;i++) "".indexOf(".");
lost = process.memory().usage-b;
result = lost < 10;