wm: teppich

Download patch

ref: a36b0984d8335858fcaf74f14214b2186b5b08b5
parent: 51f721af94855f73d8cebccb49d782f100fd3454
author: mkf <mkf@cloud9p.org>
date: Thu Nov 30 07:21:00 EST 2023

simplify a little

--- a/cmd/rc.c
+++ b/cmd/rc.c
@@ -22,10 +22,8 @@
 	}
 	
 	/* free the memory, whetever if we found a match or not */
-	for(int j = 0 ; j < argc ; j++)
-	{
+	for(int j = 0 ; j < argc+1 ; j++)
 		free(argv[j]);
-	}
 	free(argv0);
 	return status;
 }
@@ -51,7 +49,10 @@
 	{
 		for(argc = 0 ; argc < (strccnt(cmd, ' ') + 1) ; argc++)
 			argv[argc] = strcntok(cmd, ' ', argc);
+
+		argv[argc+1] = '\0'; /* just in case */
 	}
+
 	return exec(argc, argv0, argv, cwd);
 }
 
@@ -64,7 +65,6 @@
 	cwd = "/";
 	int i = 0;
 	cmd = malloc(25);
-	memset(cmd, 0, 25);
 	
 	printf("> ");
 	while(1)
@@ -79,7 +79,7 @@
 				printf("No such command\n");
 			
 			/* clear the mess */
-			memset(cmd, 0, 25);
+			memset(cmd, '\0', 25);
 			i = 0;
 			
 			printf("> ");