From 5c1f52215d083830802eff439e1f23d6c0c02651 Mon Sep 17 00:00:00 2001 From: Guy McSwain Date: Fri, 10 Jan 2020 00:50:53 -0600 Subject: [PATCH] setsockopt() with properly initialized option argument. Fixes issue #298 and possibly #274. --- pigpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pigpio.c b/pigpio.c index 24fe287..b8a7531 100644 --- 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;