shithub: ircs

Download patch

ref: 1f0209482526cfabe74ad96f4182c7d333a1c5f1
parent: 3d67aef1674ebfcc63bac043711f14ddd4765c94
author: jmq <[email protected]>
date: Wed Aug 23 18:43:07 EDT 2023

'fixed double free bug on nick change'

--- a/main.c
+++ b/main.c
@@ -52,6 +52,7 @@
 static char *post;
 static char *file;
 static char *mynick;
+static char *argvnick;
 static char *user;
 static char *addr;
 
@@ -415,7 +416,8 @@
 		logsend(m, time, &mainlog);
 
 	if(irc->pre != nil && strcmp(irc->nick, mynick) == 0){
-		free(mynick);
+		if(mynick != nil && mynick != argvnick)
+			free(mynick);
 		mynick = estrdup(newnick);
 	}
 }
@@ -976,7 +978,7 @@
 	if(argc != 2)
 		usage();
 
-	setnickuser(argv[0]);
+	setnickuser((argvnick = argv[0]));
 	addr = argv[1];
 
 	fprint(2, "initializing, please wait\n");