diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 548339a5..2b8b06de 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -4,6 +4,9 @@ * doc/UrJTAG.txt: Document the misc files under data/. + * src/bfin/bfin-part-bfin.c (bfin_part_init): Add a few more checks to avoid + segfaults and change the asserts to log warnings. + 2010-02-10 Jie Zhang * src/bsdl/Makefile.am (vhdl_flex.$(OBJEXT), bsdl_flex.$(OBJEXT)): diff --git a/urjtag/src/bfin/bfin-part-bfin.c b/urjtag/src/bfin/bfin-part-bfin.c index 3a70a08b..8991fbd1 100644 --- a/urjtag/src/bfin/bfin-part-bfin.c +++ b/urjtag/src/bfin/bfin-part-bfin.c @@ -164,7 +164,8 @@ bfin_part_init (urj_part_t *part) { int i; - assert (part && part->params); + if (!part || !part->params) + goto error; part->params->free = free; part->params->wait_ready = bfin_wait_ready; @@ -173,11 +174,14 @@ bfin_part_init (urj_part_t *part) BFIN_PART_BYPASS (part) = 0; + if (!part->active_instruction) + goto error; for (i = 0; i < NUM_SCANS; i++) if (strcmp (part->active_instruction->name, scans[i]) == 0) break; - assert (i < NUM_SCANS); + if (i == NUM_SCANS) + goto error; BFIN_PART_SCAN (part) = i; BFIN_PART_DBGCTL (part) = 0; @@ -187,6 +191,10 @@ bfin_part_init (urj_part_t *part) BFIN_PART_EMUDAT_OUT (part) = 0; BFIN_PART_EMUDAT_IN (part) = 0; BFIN_PART_EMUPC (part) = -1; + return; + + error: + urj_warning (_("Blackfin part is missing instructions\n")); } extern void bfin_init (void);