Closed Bug 876639 Opened 11 years ago Closed 11 years ago

Address unsafe references from JS_ParseJSON()

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(2 files)

JS_ParseJSON is producing a bunch of these warnings.

Convert the function to take a MutableHandleValue for its out parameter, and update callers.
Attached patch Fix the shellSplinter Review
Make JS_ParseJSON() take a MutableHandleValue and update the shell.
Attachment #754777 - Flags: review?(terrence)
Attached patch Fix the browserSplinter Review
Update references to JS_ParseJSON() in the browser to pass a handle.
Could you suggest reviewer(s) for the second patch?
Flags: needinfo?(continuation)
Attachment #754779 - Flags: review?(bugs)
Flags: needinfo?(continuation)
Attachment #754779 - Flags: review?(bugs) → review+
Comment on attachment 754777 [details] [diff] [review]
Fix the shell

Review of attachment 754777 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jsapi.cpp
@@ +6366,1 @@
>      return true;

Can this just be

return ParseJSONWithReviver(cx, JS::StableCharPtr(chars, len), len, reviver, value);

?
Comment on attachment 754777 [details] [diff] [review]
Fix the shell

Review of attachment 754777 [details] [diff] [review]:
-----------------------------------------------------------------

r=me

::: js/src/jsapi.cpp
@@ +6366,1 @@
>      return true;

It also still needs the AssertHeapIsIdle and CHECK_REQUEST, but what Msger said (assuming he meant to use |vp| directly there).
Attachment #754777 - Flags: review?(terrence) → review+
Comment on attachment 754777 [details] [diff] [review]
Fix the shell

Review of attachment 754777 [details] [diff] [review]:
-----------------------------------------------------------------

r=me

::: js/src/jsapi.cpp
@@ +6366,1 @@
>      return true;

It also still needs the AssertHeapIsIdle and CHECK_REQUEST, but what Msger said (assuming he meant to use |vp| directly there).

::: js/src/jsapi.h
@@ +4477,5 @@
>  /*
>   * JSON.parse as specified by ES5.
>   */
>  JS_PUBLIC_API(JSBool)
> +JS_ParseJSON(JSContext *cx, const jschar *chars, uint32_t len, JSMutableHandleValue vp);

One other thing occurred to me: we should probably use the external names here so that jsapi.h can serve as a useful example for embedders. So: JS::MutableHandle<JS::Value>.

In either case, we should definitely try to kill off JSMutableHandleFoo and use JS::MutableHandleFoo in all places where it comes up.
https://hg.mozilla.org/mozilla-central/rev/fd794d7e4fc1
https://hg.mozilla.org/mozilla-central/rev/681e65149dd0
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: