Closed Bug 723530 Opened 14 years ago Closed 13 years ago

double error reporting in ctype JS api implementation

Categories

(Core :: js-ctypes, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: igor, Assigned: capella)

Details

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

Attachments

(1 file)

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.
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++]
(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
Attached patch Patch (v1)Splinter Review
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 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+
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: