JavaScriptCore: Returning NULL for wrapper functions that expect JSValueRef may crash program.
According to this: http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView Returning NULL instead of an actual JSValueRef for a return value of a function could lead to crashes. I think I have seen related weirdness in the past when I failed to return a proper type to JSCore which resulted in very hard to understand behavior. So this patch changes those return NULLs to return JSValueMakeUndefined(). I thought about JSObjectMakeError, but I don't fully understand the intent of the Error object and can't find any relevant real world examples of it being used. However, everybody seems to be using JSValueMakeUndefined(). This patch should be low impact since this is only triggered on an error condition.
This commit is contained in:
parent
6f69555225
commit
f1c331f2c5
1 changed files with 5 additions and 5 deletions
|
|
@ -17,7 +17,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size
|
|||
return SWIG_JSC_NewPointerObj(context, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||
goto fail;
|
||||
fail:
|
||||
return NULL;
|
||||
return JSValueMakeUndefined(context);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size
|
|||
|
||||
goto fail;
|
||||
fail:
|
||||
return NULL;
|
||||
return JSValueMakeUndefined(context);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStr
|
|||
|
||||
goto fail;
|
||||
fail:
|
||||
return NULL;
|
||||
return JSValueMakeUndefined(context);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjec
|
|||
|
||||
goto fail;
|
||||
fail:
|
||||
return NULL;
|
||||
return JSValueMakeUndefined(context);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjec
|
|||
|
||||
goto fail;
|
||||
fail:
|
||||
return NULL;
|
||||
return JSValueMakeUndefined(context);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue