]> git.gsnw.org Git - fping.git/commitdiff
initialize all resp_times array entries
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sun, 24 Aug 2025 12:44:08 +0000 (14:44 +0200)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Tue, 26 Aug 2025 18:17:52 +0000 (20:17 +0200)
Before, the resp_times array was initialized starting with the
second entry, leaving the first entry uninitialized.  This is
at least confusing.  Initializing one additional int64_t value
per ping target should not add too much overhead, so do this just
to be on the safe side.

Assuming that the first array entry need not be initialized when
creating the array now, this guards against potential problems
from future code changes that do not take this unexpected special
case into account.

src/fping.c

index 8db952ac41c66c746809ffaf666dae6518875210..e9d89bff77cb2348e8e64ee0fd926e457a97aa84 100644 (file)
@@ -3548,7 +3548,7 @@ void add_addr(char *name, char *host, struct sockaddr *ipaddr, socklen_t ipaddr_
         if (!i)
             crash_and_burn("can't allocate resp_times array");
 
-        for (n = 1; n < trials; n++)
+        for (n = 0; n < trials; n++)
             i[n] = RESP_UNUSED;
 
         p->resp_times = i;