🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by James Buster Wed, 27 Jan 1993 03:22
memory leak fixes to make 3.63
#1356
Author: James Buster
Date: Wed, 27 Jan 1993 03:22
62 lines
2575 bytes
Here is a unified diff to fix memory leaks in commands.c:

--- commands.c.orig	Tue Jan 26 13:46:57 1993
+++ commands.c	Tue Jan 26 13:48:12 1993
@@ -36,7 +36,7 @@
      register struct file *file;
 {
   register char *p;
-  char *at, *percent, *star, *less;
+  char *at, *percent, *star, *less, *save;
 
 #define	DEFINE_VARIABLE(name, len, value) \
   (void) define_variable_for_file (name, len, value, o_automatic, 0, file)
@@ -56,7 +56,7 @@
 #endif	/* NO_ARCHIVES.  */
     {
       at = savestring (file->name, strlen (file->name));
-      percent = "";
+      percent = savestring ("", 0);
     }
 
   DEFINE_VARIABLE ("@", 1, at);
@@ -64,8 +64,8 @@
 
 #define	LASTSLASH(s)	rindex ((s), '/')
 #define	FILEONLY(s)	(p != 0 ? p + 1 : (s))
-#define	DIRONLY(s)	(p == 0 ? "./" : p == (s) ? "/" \
-			 : savestring ((s), (p - (s)) + 1))
+#define	DIRONLY(s)	(p == 0 ? savestring ("./", 2) : p == (s) ? \
+			 savestring ("/", 1) : savestring ((s), (p - (s)) + 1))
 
   /* $* is the stem from an implicit or static pattern rule.  */
   if (file->stem == 0)
@@ -118,17 +118,24 @@
 
   /* Set up the D and F versions.  */
   p = LASTSLASH (at);
-  DEFINE_VARIABLE ("@D", 2, DIRONLY (at));
+  DEFINE_VARIABLE ("@D", 2, save = DIRONLY (at));
+  free (save);
   DEFINE_VARIABLE ("@F", 2, FILEONLY (at));
   p = LASTSLASH (star);
-  DEFINE_VARIABLE ("*D", 2, DIRONLY (star));
+  DEFINE_VARIABLE ("*D", 2, save = DIRONLY (star));
+  free (save);
   DEFINE_VARIABLE ("*F", 2, FILEONLY (star));
   p = LASTSLASH (less);
-  DEFINE_VARIABLE ("<D", 2, DIRONLY (less));
+  DEFINE_VARIABLE ("<D", 2, save = DIRONLY (less));
+  free (save);
   DEFINE_VARIABLE ("<F", 2, FILEONLY (less));
   p = LASTSLASH (percent);
-  DEFINE_VARIABLE ("%D", 2, DIRONLY (percent));
+  DEFINE_VARIABLE ("%D", 2, save = DIRONLY (percent));
+  free (save);
   DEFINE_VARIABLE ("%F", 2, FILEONLY (percent));
+
+  free (at);
+  free (percent);
 
   /* Make sure that no dependencies are repeated.  This does not
      really matter for the purpose of updating targets, but it
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads