double error reporting in ctype JS api implementation

RESOLVED FIXED in mozilla15

Status

()

Core
js-ctypes
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: Igor Bukanov, Assigned: capella)

Tracking

unspecified
mozilla15
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [mentor=jdm][lang=c++])

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
In many places ctypes implementation contains the following code:

  JSObject* obj = JS_THIS_OBJECT(cx, vp);
  if (!obj || !(CType::IsCType(obj) || CType::IsCTypeProto(obj))) {
    JS_ReportError(cx, "not a CType");
    return JS_FALSE;
  }

That is, the error is reported when JS_THIS_OBJECT(cx, vp) returns false. However, JS_THIS_OBJECT(cx, vp) already reports an error when it fails leading to bogus second error report and stopping of OOM propagation that triggered JS_THIS_OBJECT failure.

Comment 1

6 years ago
I assume the correct fix is to move the null check out of the condition and into an early return?
Whiteboard: [mentor=jdm][lang=c++]
(Reporter)

Comment 2

6 years ago
(In reply to Josh Matthews [:jdm] from comment #1)
> I assume the correct fix is to move the null check out of the condition and
> into an early return?

Yes
(Assignee)

Comment 3

5 years ago
Created attachment 619146 [details] [diff] [review]
Patch (v1)

Have a look at the patch, I think it's what you're after.

It builds clean and mochitest-plain passes locally on my WIN7 machine.
Assignee: nobody → markcapella
Status: NEW → ASSIGNED
Attachment #619146 - Flags: feedback?(josh)

Comment 4

5 years ago
Comment on attachment 619146 [details] [diff] [review]
Patch (v1)

Yep, that looks right to me. Onwards, brave reviewers!
Attachment #619146 - Flags: review?(bobbyholley+bmo)
Attachment #619146 - Flags: feedback?(josh)
Attachment #619146 - Flags: feedback+
Attachment #619146 - Flags: review?(bobbyholley+bmo) → review+

Comment 5

5 years ago
http://hg.mozilla.org/integration/mozilla-inbound/rev/100e249720c1
Target Milestone: --- → mozilla15
https://hg.mozilla.org/mozilla-central/rev/100e249720c1
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.