Browse Source

Fix memory leaks

Fix a memory leak on each login; the allocated OpenSSL BIOs were only
freed partially.

Also add a missing deallocation during server socket creation.
Santtu Lakkala 1 month ago
parent
commit
11d1adca7a
2 changed files with 3 additions and 1 deletions
  1. 1 1
      xs_openssl.h
  2. 2 0
      xs_socket.h

+ 1 - 1
xs_openssl.h

@@ -83,7 +83,7 @@ xs_val *xs_base64_dec(const xs_str *data, int *size)
     s = xs_realloc(s, _xs_blk_size(*size + 1));
     s[*size] = '\0';
 
-    BIO_free_all(mem);
+    BIO_free_all(b64);
 
     return s;
 }

+ 2 - 0
xs_socket.h

@@ -85,6 +85,8 @@ int xs_socket_server(const char *addr, const char *serv)
       listen(rs, SOMAXCONN);
     }
 
+    freeaddrinfo(res);
+
 #else /* WITHOUT_GETADDRINFO */
    struct sockaddr_in host;