Move control bit number check before mallocs in bsbit_alloc

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1561 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Rutger Hofman 16 years ago
parent 3e0430466d
commit e99a3289b6

@ -61,6 +61,11 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
urj_error_set(URJ_ERROR_ALREADY, _("duplicate bit declaration"));
return URJ_STATUS_FAIL;
}
if (ctrl_num != -1 && ctrl_num >= bsr->in->len)
{
urj_error_set(URJ_ERROR_INVALID, _("invalid control bit number\n"));
return URJ_STATUS_FAIL;
}
signal = urj_part_find_signal (part, name);
@ -108,11 +113,6 @@ urj_part_bsbit_alloc_control (urj_part_t *part, int bit, const char *name,
if (ctrl_num != -1)
{
if (ctrl_num >= bsr->in->len)
{
urj_error_set(URJ_ERROR_INVALID, _("invalid control bit number\n"));
return URJ_STATUS_FAIL;
}
b->control = ctrl_num;
b->control_value = ctrl_val;
b->control_state = URJ_BSBIT_STATE_Z;

Loading…
Cancel
Save