setsockopt() with properly initialized option argument. Fixes issue #298 and possibly...
authorGuy McSwain <guy.mcswain@gmail.com>
Fri, 10 Jan 2020 06:50:53 +0000 (00:50 -0600)
committerGuy McSwain <guy.mcswain@gmail.com>
Fri, 10 Jan 2020 06:50:53 +0000 (00:50 -0600)
pigpio.c

index 24fe28774a68e9e2cf36eb3a3e35fe4b38807d7a..b8a75317c6b45c4fa4b9c67b1e68de705c33f792 100644 (file)
--- a/pigpio.c
+++ b/pigpio.c
@@ -8292,7 +8292,7 @@ int initInitialise(void)
             }
             server6.sin6_port = htons(port);
 
-            int opt;
+            int opt = 1;
             setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
             if (bind(fdSock,(struct sockaddr *)&server6, sizeof(server6)) < 0)
                SOFT_ERROR(PI_INIT_FAILED, "bind to port %d failed (%m)", port);
@@ -8307,7 +8307,7 @@ int initInitialise(void)
             SOFT_ERROR(PI_INIT_FAILED, "socket failed (%m)");
          else
          {
-           int opt;
+           int opt = 1;
            setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
          }
          server.sin_family = AF_INET;