about summary refs log tree commit diff stats
path: root/src/main.c
diff options
context:
space:
mode:
authorRen Kararou <[email protected]>2025-01-25 20:20:37 -0600
committerRen Kararou <[email protected]>2025-01-25 20:20:37 -0600
commit9ec8d6d9dc03791f6ab1e3ad108c8d705d355696 (patch)
treeeaa277a55a1bc5d4db89e3db9f4785becdcbacd3 /src/main.c
parenta9bddce6d690838d8bfb586da918c406dd853e93 (diff)
downloadnbtpd-9ec8d6d9dc03791f6ab1e3ad108c8d705d355696.tar.gz
nbtpd-9ec8d6d9dc03791f6ab1e3ad108c8d705d355696.tar.bz2
nbtpd-9ec8d6d9dc03791f6ab1e3ad108c8d705d355696.zip
fix memory leak in main loop; fix memory leak in handlers.c HEAD canon
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index fc5835b..7114cc7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -279,12 +279,7 @@ int main(int argc, char **argv) {
 			}
 		}
 		//TODO: use std threads
-		pthread_t *_thread = malloc(sizeof(pthread_t));
-		if (_thread == NULL) {
-			syslog(LOG_CRIT, "unable to allocate memory: %s", strerror(errno));
-			free(args);
-			continue;
-		}
+		pthread_t _thread;
 		void *(*func)(void *);
 		switch (oc) {
 			case RRQ:
@@ -300,15 +295,12 @@ int main(int argc, char **argv) {
 		//TODO: use std threads
 		int e;
 		syslog(LOG_ERR, "spawning thread for %s", inet_ntoa(caddr.sin_addr));
-//		void *lol = func((void *)args);
-//		free(lol);
-		if ((e = pthread_create(_thread, 0, func, (void *)args)) != 0) {
+		if ((e = pthread_create(&_thread, 0, func, (void *)args)) != 0) {
 			syslog(
 				LOG_CRIT,
 				"unable to spawn thread: %s",
 				strerror(e)
 			);
-			free(_thread);
 			free(args);
 		}
 	}