From b9fa0b8b2b0ddadfd6adbb8d488aa8f2e34ccf35 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Tue, 4 Jun 2002 18:13:55 +0000 Subject: [PATCH] Respect addProperty failure (148899, r=khanson, sr=shaver). --- js/src/jsobj.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/src/jsobj.c b/js/src/jsobj.c index 79d56bbfc65..adb7f333a5e 100644 --- a/js/src/jsobj.c +++ b/js/src/jsobj.c @@ -2084,8 +2084,10 @@ js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, jsval value, goto bad; /* XXXbe called with lock held */ - if (!clasp->addProperty(cx, obj, SPROP_USERID(sprop), &value)) + if (!clasp->addProperty(cx, obj, SPROP_USERID(sprop), &value)) { + (void) js_RemoveScopeProperty(cx, scope, id); goto bad; + } PROPERTY_CACHE_FILL(&cx->runtime->propertyCache, obj, id, sprop); if (SPROP_HAS_VALID_SLOT(sprop, scope)) @@ -2651,6 +2653,7 @@ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp) /* XXXbe called with obj locked */ if (!clasp->addProperty(cx, obj, SPROP_USERID(sprop), vp)) { + (void) js_RemoveScopeProperty(cx, scope, id); JS_UNLOCK_SCOPE(cx, scope); return JS_FALSE; }