Bug 777292 - Make sure that the Components.lastResult is interpreted as unsigned integers; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2012-09-21 14:45:57 -04:00
parent 1a8367de54
commit e53b0b3938

View File

@ -1403,7 +1403,7 @@ nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
nsresult rv;
while (nsXPCException::IterateNSResults(&rv, &rv_name, nullptr, &iter)) {
if (!strcmp(name.ptr(), rv_name)) {
// The double cast below is required since nsresult is an enum,
// The two casts below is required since nsresult is an enum,
// and it can be interpreted as a signed integer if we directly
// cast to a double.
jsval val = JS_NumberValue((double)(uint32_t)rv);
@ -4721,7 +4721,10 @@ nsXPCComponents::GetProperty(nsIXPConnectWrappedNative *wrapper,
nsresult rv = NS_OK;
if (doResult) {
*vp = JS_NumberValue((double) res);
// The two casts below is required since nsresult is an enum,
// and it can be interpreted as a signed integer if we directly
// cast to a double.
*vp = JS_NumberValue((double)(uint32_t) res);
rv = NS_SUCCESS_I_DID_SOMETHING;
}
@ -4873,4 +4876,4 @@ nsXPCComponents::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *glob
}
*parentObj = mScope->GetGlobalJSObject();
return NS_OK;
}
}