Fix js_LineNumberToPC based on MikeM@RetekSolutions.com's input (313922, r=mrbkap).
Fix js_LineNumberToPC based on MikeM@RetekSolutions.com's input (313922, r=mrbkap).
--- a/js/src/jsscript.c
+++ b/js/src/jsscript.c
@@ -1627,19 +1627,23 @@ js_LineNumberToPC(JSScript *script, uint
jssrcnote *sn;
JSSrcNoteType type;
offset = 0;
best = -1;
lineno = script->lineno;
bestdiff = SN_LINE_LIMIT;
for (sn = SCRIPT_NOTES(script); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
- if (lineno == target)
+ /*
+ * Exact-match only if offset is not in the prolog; otherwise use
+ * nearest greater-or-equal line number match.
+ */
+ if (lineno == target && script->code + offset >= script->main)
goto out;
- if (lineno > target) {
+ if (lineno >= target) {
diff = lineno - target;
if (diff < bestdiff) {
bestdiff = diff;
best = offset;
}
}
offset += SN_DELTA(sn);
type = (JSSrcNoteType) SN_TYPE(sn);