]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib530: simplify realloc failure exit path
authorDaniel Stenberg <daniel@haxx.se>
Tue, 30 Aug 2022 11:46:03 +0000 (13:46 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 30 Aug 2022 13:38:20 +0000 (15:38 +0200)
To make code analyzers happier

Closes #9392

tests/libtest/lib530.c

index 1ab990780e9b23bc63fc748a54040a53ce151864..22577275cda7ad6ed25bab8d455d409c6c69b0e2 100644 (file)
@@ -92,14 +92,12 @@ static int addFd(struct Sockets *sockets, curl_socket_t fd, const char *what)
     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) {
+    curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) *
+                                 (sockets->max_count + 20));
+    if(!ptr)
       /* cleanup in test_cleanup */
-      sockets->sockets = oldptr;
       return 1;
-    }
+    sockets->sockets = ptr;
     sockets->max_count += 20;
   }
   /*
@@ -361,7 +359,6 @@ test_cleanup:
   /* free local memory */
   free(sockets.read.sockets);
   free(sockets.write.sockets);
-
   return res;
 }