]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib582: remove code causing warning that is never run
authorDaniel Stenberg <daniel@haxx.se>
Wed, 7 Feb 2024 13:06:56 +0000 (14:06 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 7 Feb 2024 14:45:29 +0000 (15:45 +0100)
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

tests/libtest/lib582.c

index a50f8a429f789fd494757c26e4f49c6f8c1d9a4e..8fe6402a49c59187cfddcd585c88cea3b04f3379 100644 (file)
@@ -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.