From 5a95c31414f0544b2438d08547170fe7bae13056 Mon Sep 17 00:00:00 2001 From: bal Date: Wed, 23 Jan 1985 16:13:57 +0000 Subject: [PATCH] bug fixed in last_mnem(): test on nil-pointer. bug fixed in try_tail(): add line "if(l1==0||l2==0) return FALSE". --- util/ego/cj/cj.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/ego/cj/cj.c b/util/ego/cj/cj.c index 3c27ebcec..bc4a250bf 100644 --- a/util/ego/cj/cj.c +++ b/util/ego/cj/cj.c @@ -83,7 +83,9 @@ STATIC line_p last_mnem(b) register line_p l; for (l = b->b_start; l->l_next != (line_p) 0; l = l->l_next); - while (INSTR(l) < sp_fmnem || INSTR(l) > sp_lmnem) l = PREV(l); + while (l != (line_p) 0 && (INSTR(l) < sp_fmnem || INSTR(l) > sp_lmnem)) { + l = PREV(l); + } return l; } @@ -205,6 +207,7 @@ STATIC bool try_tail(b1,b2) if (b1->b_start == (line_p) 0 || b2->b_start == (line_p) 0) return FALSE; l1 = last_mnem(b1); l2 = last_mnem(b2); + if (l1 == (line_p) 0 || l2 == (line_p) 0) return FALSE; /* printf("consider:\n"); showinstr(l1); showinstr(l2); */ if (INSTR(l1) == op_bra) { b = b1; -- 2.34.1