Last Comment Bug 723530 - double error reporting in ctype JS api implementation
: double error reporting in ctype JS api implementation
Status: RESOLVED FIXED
[mentor=jdm][lang=c++]
:
Product: Core
Classification: Components
Component: js-ctypes (show other bugs)
: unspecified
: x86_64 Linux
: -- normal (vote)
: mozilla15
Assigned To: Mark Capella [:capella]
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-02-02 08:07 PST by Igor Bukanov
Modified: 2012-04-30 08:01 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (v1) (13.64 KB, patch)
2012-04-27 12:47 PDT, Mark Capella [:capella]
bobbyholley: review+
josh: feedback+
Details | Diff | Splinter Review

Description Igor Bukanov 2012-02-02 08:07:38 PST
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 Josh Matthews [:jdm] 2012-02-07 20:36:25 PST
I assume the correct fix is to move the null check out of the condition and into an early return?
Comment 2 Igor Bukanov 2012-02-08 00:31:43 PST
(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
Comment 3 Mark Capella [:capella] 2012-04-27 12:47:48 PDT
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.
Comment 4 Josh Matthews [:jdm] 2012-04-27 12:58:13 PDT
Comment on attachment 619146 [details] [diff] [review]
Patch (v1)

Yep, that looks right to me. Onwards, brave reviewers!

Note You need to log in before you can comment on or make changes to this bug.