[COMMITTED] algol68: ga68-posix.c: fix _libga68_posixfconnect

Jose E. Marchesi jemarch@gnu.org
Sun Apr 20 22:42:01 GMT 2025


---
 libga68/ga68-posix.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libga68/ga68-posix.c b/libga68/ga68-posix.c
index 5e72d428496..00aa414bab9 100644
--- a/libga68/ga68-posix.c
+++ b/libga68/ga68-posix.c
@@ -341,7 +341,7 @@ _libga68_posixfconnect (uint32_t *str, size_t len, size_t stride,
   int fd = socket (AF_INET, SOCK_STREAM, 0);
   _libga68_errno = errno;
   if (fd < 0)
-    goto end;
+    goto error;
 
   /* Lookup the specified host.  */
   char *host = _libga68_malloc (u8len + 1);
@@ -351,7 +351,7 @@ _libga68_posixfconnect (uint32_t *str, size_t len, size_t stride,
   if (server == NULL)
     {
       _libga68_errno = h_errno;
-      goto close_fd;
+      goto close_fd_and_error;
     }
 
   /* Connect the socket to the server.  */
@@ -366,15 +366,14 @@ _libga68_posixfconnect (uint32_t *str, size_t len, size_t stride,
 		     sizeof (serv_addr));
   _libga68_errno = errno;
   if (res == -1)
-    goto close_fd;
-
- close_fd:
-  close (fd);
-  fd = -1;
+    goto close_fd_and_error;
 
   _libga68_free (host);
-
-  /* Return the file descriptor for the socket.  */
- end:
   return fd;
+
+ close_fd_and_error:
+  close (fd);
+ error:
+  _libga68_free (host);
+  return -1;
 }
-- 
2.30.2



More information about the Algol68 mailing list