mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 763384 - Don't treat regexp syntax errors as OOM errors (r=njn)
This commit is contained in:
parent
ebf032432b
commit
28d1e3621d
@ -21,6 +21,7 @@
|
||||
#include "jstypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include "mozilla/Scoped.h"
|
||||
|
||||
/* The public JS engine namespace. */
|
||||
namespace JS {}
|
||||
@ -594,6 +595,15 @@ public:
|
||||
class UnwantedForeground : public Foreground {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ScopedDeletePtrTraits
|
||||
{
|
||||
typedef T *type;
|
||||
static T *empty() { return NULL; }
|
||||
static void release(T *ptr) { Foreground::delete_(ptr); }
|
||||
};
|
||||
SCOPED_TEMPLATE(ScopedDeletePtr, ScopedDeletePtrTraits)
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
/*
|
||||
|
9
js/src/jit-test/tests/basic/testBug763384.js
Normal file
9
js/src/jit-test/tests/basic/testBug763384.js
Normal file
@ -0,0 +1,9 @@
|
||||
var caught = false;
|
||||
try {
|
||||
''.match('(');
|
||||
} catch (e) {
|
||||
caught = true;
|
||||
assertEq(e instanceof Error, true);
|
||||
assertEq(('' + e).indexOf('SyntaxError') === -1, false);
|
||||
}
|
||||
assertEq(caught, true);
|
@ -560,29 +560,26 @@ RegExpCompartment::get(JSContext *cx, JSAtom *keyAtom, JSAtom *source, RegExpFla
|
||||
return true;
|
||||
}
|
||||
|
||||
RegExpShared *shared = cx->runtime->new_<RegExpShared>(cx->runtime, flags);
|
||||
ScopedDeletePtr<RegExpShared> shared(cx->new_<RegExpShared>(cx->runtime, flags));
|
||||
if (!shared)
|
||||
goto error;
|
||||
return false;
|
||||
|
||||
if (!shared->compile(cx, source))
|
||||
goto error;
|
||||
return false;
|
||||
|
||||
/* Re-lookup in case there was a GC. */
|
||||
if (!map_.relookupOrAdd(p, key, shared))
|
||||
goto error;
|
||||
if (!map_.relookupOrAdd(p, key, shared)) {
|
||||
js_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Since 'error' deletes 'shared', only guard 'shared' on success. This is
|
||||
* safe since 'shared' cannot be deleted by GC until after the call to
|
||||
* map_.add() directly above.
|
||||
* map_.relookupOrAdd() directly above.
|
||||
*/
|
||||
g->init(*shared);
|
||||
g->init(*shared.forget());
|
||||
return true;
|
||||
|
||||
error:
|
||||
Foreground::delete_(shared);
|
||||
js_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user