Closed
Bug 510360
Opened 16 years ago
Closed 15 years ago
early return in json.cpp might skip necessary postamble
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
status1.9.2 | --- | beta4-fixed |
People
(Reporter: luke, Assigned: luke)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
4.29 KB,
patch
|
sayrer
:
review+
|
Details | Diff | Splinter Review |
In the big loop in the function 'JO' in json.cpp, it appears that most of the code funnels through a postamble after the loop that closes an iterator. However, there are a few early returns in the loop that skip this close.
I'm not well versed in json or iterators, so perhaps there is a reason these early exits are fine. If the reason isn't obvious, perhaps it could be added as a comment.
Comment 1•16 years ago
|
||
The GC will take care of the iterator, no js_CloseIterator required. It helps to promptly free memory, so worth doing, but control flow is a bit fussy already in JO. To make it fussier but consistent, all those early return JS_FALSE; statements should be breaks after if (!ok) tests, where ok = the condition after the ! in the existing condition, e.g.
ok = scx->replacer->getProperty(cx, key, &newKey);
if (!ok)
break;
/be
Comment 2•16 years ago
|
||
Alternatively, for simpler code, get rid of the ok setting and if (!ok) break; jazz, and the if (!ok) return JS_FALSE; after the conditional js_CloseIterator, and just return early on error.
/be
![]() |
Assignee | |
Comment 3•16 years ago
|
||
This patch normalizes the control flow so the iterators are always closed. Shorter code too.
Comment 4•15 years ago
|
||
You have a patch on this bug that is flagged for 'review?' and not assigned to any reviewer. If you want the patch to be reviewed please assign a reviewer. Thanks
Updated•15 years ago
|
Attachment #394668 -
Flags: review? → review+
![]() |
Assignee | |
Comment 5•15 years ago
|
||
Whiteboard: fixed-in-tracemonkey
Comment 6•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: wanted1.9.2+
Resolution: --- → FIXED
Comment 7•15 years ago
|
||
status1.9.2:
--- → final-fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•