toolkit/components/ctypes uses the wrong global object

RESOLVED FIXED

Status

()

Core
js-ctypes
RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: zwol, Assigned: dwitte@gmail.com)

Tracking

Trunk
x86_64
Linux
Points:
---

Firefox Tracking Flags

(blocking2.0 beta4+)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 attachment)

(Reporter)

Description

8 years ago
http://mxr.mozilla.org/mozilla-central/source/toolkit/components/ctypes/Module.cpp#107 reads:

107 NS_IMETHODIMP
108 Module::Call(nsIXPConnectWrappedNative* wrapper,
109              JSContext* cx,
110              JSObject* obj,
111              PRUint32 argc,
112              jsval* argv,
113              jsval* vp,
114              PRBool* _retval)
115 {
116   JSObject* global = JS_GetGlobalObject(cx);
117   *_retval = InitAndSealCTypesClass(cx, global);
118   return NS_OK;
119 }

Per jst, this is not the correct global object to use here: it should instead look something like this:

{
  JSObject* scope = JS_GetScopeChain(cx);
  if (!scope)
    return NS_ERROR_NOT_AVAILABLE;

  JSObject* global = JS_GetGlobalForObject(cx, scope);
  if (!global)
    return NS_ERROR_NOT_AVAILABLE;

  *_retval = InitAndSealCTypesClass(cx, global);
  return NS_OK;
}
(Assignee)

Comment 1

8 years ago
Created attachment 462527 [details] [diff] [review]
patch

If jst says so! jorendorff, does this look right to you?
Assignee: nobody → dwitte
Status: NEW → ASSIGNED
Attachment #462527 - Flags: review?(jorendorff)
Comment on attachment 462527 [details] [diff] [review]
patch

Right ...but you might as well use JS_GetGlobalForScopeChain(cx), which does the same thing in a single call.
Attachment #462527 - Flags: review?(jorendorff) → review+
(Assignee)

Comment 3

8 years ago
Comment on attachment 462527 [details] [diff] [review]
patch

Will do. Simple correctness fix; requesting approval.
Attachment #462527 - Flags: approval2.0?

Updated

8 years ago
blocking2.0: --- → beta4+

Updated

8 years ago
Attachment #462527 - Flags: approval2.0?
(Assignee)

Comment 4

8 years ago
http://hg.mozilla.org/tracemonkey/rev/736566d21998
Whiteboard: fixed-in-tracemonkey

Comment 5

8 years ago
http://hg.mozilla.org/mozilla-central/rev/736566d21998
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.