From f94795401a56d366aa2e6343c439d0a5ff1b2c8c Mon Sep 17 00:00:00 2001 From: "brendan@mozilla.org" Date: Mon, 2 Apr 2007 11:13:22 -0700 Subject: [PATCH] Fix js_LineNumberToPC based on MikeM@RetekSolutions.com's input (313922, r=mrbkap). --- js/src/jsscript.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/src/jsscript.c b/js/src/jsscript.c index c91b0b06288d..d86912c08f71 100644 --- a/js/src/jsscript.c +++ b/js/src/jsscript.c @@ -1632,9 +1632,13 @@ js_LineNumberToPC(JSScript *script, uintN target) 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;