From e99a3289b69e941d90459ab948454d5c99f9e0ff Mon Sep 17 00:00:00 2001 From: Rutger Hofman Date: Tue, 5 May 2009 13:24:38 +0000 Subject: [PATCH] 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 --- urjtag/src/part/bsbit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/urjtag/src/part/bsbit.c b/urjtag/src/part/bsbit.c index 6f9c2a89..53e8ca1f 100644 --- a/urjtag/src/part/bsbit.c +++ b/urjtag/src/part/bsbit.c @@ -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;