From b06ed92557bfe73c542cabf21d23c483f489aa0a Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 25 May 2012 18:21:09 -0300 Subject: [PATCH] inst.h (FOR_PKG_INSTS): protect against active_pkg == NULL active_pkg can become NULL if the root frame contains a loop that will never execute, i.e., loop x = 1, 0 This caused fped to segfault when FOR_PKG_INSTS was called from FOR_ALL_INSTS in inst_draw. --- inst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst.h b/inst.h index badfb33..b64ed29 100644 --- a/inst.h +++ b/inst.h @@ -155,7 +155,7 @@ extern struct inst *frame_instantiating; for (prio = ip_n-1; prio != (enum inst_prio) -1; prio--) #define FOR_PKG_INSTS(pkg, prio, inst) \ - for (inst = (pkg)->insts[prio]; inst; inst = inst->next) + for (inst = (pkg) ? (pkg)->insts[prio] : NULL; inst; inst = inst->next) #define FOR_ALL_INSTS(i, prio, inst) \ for (i = 0; i != 2; i++) \