mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Fixed memory leak in ''.indexOf('.')
This commit is contained in:
parent
7b9195b3bf
commit
312cb7f3a6
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
9
tests/test_string_indexof_2.js
Normal file
9
tests/test_string_indexof_2.js
Normal 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;
|
||||
Loading…
x
Reference in New Issue
Block a user