From: Fabian Keil Date: Sat, 30 May 2020 07:20:16 +0000 (+0200) Subject: remember_connection(): Add assertion to silence bogus cppcheck warnings X-Git-Tag: v_3_0_29~358 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=baaf5d0a1efd2eb231a93777019464c5b4cbe7b7;ds=inline remember_connection(): Add assertion to silence bogus cppcheck warnings gateway.c:221:23: error: Array 'reusable_connection[100]' accessed at index 100, which is out of bounds. [arrayIndexOutOfBounds] reusable_connection[slot].host = strdup_or_die(connection->host); ^ gateway.c:198:4: note: After for loop, slot has value 100 for (slot = 0; slot < SZ(reusable_connection); slot++) ^ [...] --- diff --git a/gateway.c b/gateway.c index f5d15a56..64ba5236 100644 --- a/gateway.c +++ b/gateway.c @@ -218,6 +218,7 @@ void remember_connection(const struct reusable_connection *connection) return; } + assert(slot < SZ(reusable_connection)); assert(NULL != connection->host); reusable_connection[slot].host = strdup_or_die(connection->host); reusable_connection[slot].sfd = connection->sfd;