From: Daniel Stenberg Date: Wed, 7 Feb 2024 13:06:56 +0000 (+0100) Subject: lib582: remove code causing warning that is never run X-Git-Tag: curl-8_7_0~203 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1c9f38b8c5c531e12166a6537d0ffab52ac197e;p=thirdparty%2Fcurl.git lib582: remove code causing warning that is never run The previous realloc code in this code could trigger a compiler warning, but since that code path cannot happen in normal circumstances it now instead exits with an error message there. Ref: #12887 Closes #12890 --- diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index a50f8a429f..8fe6402a49 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -83,16 +83,10 @@ static void addFd(struct Sockets *sockets, curl_socket_t fd, const char *what) return; sockets->max_count = 20; } - else if(sockets->count + 1 > sockets->max_count) { - curl_socket_t *oldptr = sockets->sockets; - sockets->sockets = realloc(oldptr, sizeof(curl_socket_t) * - (sockets->max_count + 20)); - if(!sockets->sockets) { - /* cleanup in test_cleanup */ - sockets->sockets = oldptr; - return; - } - sockets->max_count += 20; + else if(sockets->count >= sockets->max_count) { + /* this can't happen in normal cases */ + fprintf(stderr, "too many file handles error\n"); + exit(2); } /* * Add file descriptor to array.