aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2013-09-24 15:32:22 +0300
committerArnold D. Robbins <arnold@skeeve.com>2013-09-24 15:32:22 +0300
commit33db472fbf2c90395937d3dbd9c08bf591fb2ecd (patch)
tree17469f1f16d81638f29be9a072af5acfe0b8b597
parenta4a5f76e51cd51af470fcaa85f5f1360ecd18b0c (diff)
downloadegawk-33db472fbf2c90395937d3dbd9c08bf591fb2ecd.tar.gz
egawk-33db472fbf2c90395937d3dbd9c08bf591fb2ecd.tar.bz2
egawk-33db472fbf2c90395937d3dbd9c08bf591fb2ecd.zip
Fix core dump in debug.c for breakpoint w/o line.
-rw-r--r--ChangeLog6
-rw-r--r--debug.c18
2 files changed, 18 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f87d21d..f7996397 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-24 Arnold D. Robbins <arnold@skeeve.com>
+
+ * debug.c (find_rule): Handle case where lineno is zero. Can happen
+ if break is given without a line number on a current line. Thanks
+ to Ray Song <i@maskray.me> for the report.
+
2013-09-19 Arnold D. Robbins <arnold@skeeve.com>
* dfa.c (parse_bracket_exp): Use code from grep to keep things within
diff --git a/debug.c b/debug.c
index 949ebb49..357ce725 100644
--- a/debug.c
+++ b/debug.c
@@ -2068,12 +2068,18 @@ find_rule(char *src, long lineno)
{
INSTRUCTION *rp;
- assert(lineno > 0);
- for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) {
- if ((rp - 1)->source_file == src
- && lineno >= (rp + 1)->first_line
- && lineno <= (rp + 1)->last_line)
- return (rp - 1);
+ if (lineno == 0) {
+ for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) {
+ if ((rp - 1)->source_file == src && (rp - 1)->source_line > 0)
+ return (rp - 1);
+ }
+ } else {
+ for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) {
+ if ((rp - 1)->source_file == src
+ && lineno >= (rp + 1)->first_line
+ && lineno <= (rp + 1)->last_line)
+ return (rp - 1);
+ }
}
return NULL;
}