diff --git a/src/stick_table.c b/src/stick_table.c index 3429d047c..86ea3ceea 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -2148,8 +2148,6 @@ smp_fetch_sc_stkctr(struct session *sess, struct stream *strm, const struct arg if (num == '_' - '0') { /* sc_* variant, args[0] = ctr# (mandatory) */ num = args[arg++].data.sint; - if (num >= MAX_SESS_STKCTR) - return NULL; } else if (num > 9) { /* src_* variant, args[0] = table */ struct stktable_key *key; @@ -2180,7 +2178,10 @@ smp_fetch_sc_stkctr(struct session *sess, struct stream *strm, const struct arg * the sc[0-9]_ form, or even higher using sc_(num) if needed. * args[arg] is the first optional argument. We first lookup the * ctr form the stream, then from the session if it was not there. + * But we must be sure the counter does not exceed MAX_SESS_STKCTR. */ + if (num >= MAX_SESS_STKCTR) + return NULL; if (strm) stkptr = &strm->stkctr[num];