[mw-devel] [Git][arthur/mw][master] 2 commits: Fixes a segv and other wrong behaviours from changing to use AUTOFREE_BUFFERs

Dom Rushbrook psycodom at sucs.org
Thu Oct 29 11:08:16 GMT 2015


Dom Rushbrook pushed to branch master at Justin Mitchell / mw


Commits:
08e6e5e0 by Dom Rushbrook at 2015-10-29T10:34:52Z
Fixes a segv and other wrong behaviours from changing to use AUTOFREE_BUFFERs

- - - - -
b7561512 by Dom Rushbrook at 2015-10-29T10:40:31Z
Merge branch 'master' of projects.sucs.org:arthur/mw

- - - - -


1 changed file:

- src/client/script_inst.c


Changes:

=====================================
src/client/script_inst.c
=====================================
--- a/src/client/script_inst.c
+++ b/src/client/script_inst.c
@@ -174,7 +174,7 @@ void scr_time( struct code *pc, int fargc, char **fargv )
 		}
 
 		/* set default idle time to zero */
-		snprintf(value, MAXTEXTLENGTH - 1, "0");
+		string_add(&value, "0");
 
 		size_t wi;
 		json_t *entry;
@@ -184,7 +184,7 @@ void scr_time( struct code *pc, int fargc, char **fargv )
 
 			if (!strcasecmp(name, uname))
 			{
-				snprintf(value, MAXTEXTLENGTH - 1, "%ld", now - idletime);
+				string_add(&value, "%ld", now - idletime);
 				if (script_debug) printf("- %s: Idletime is %ld\n", pc->inst->name, now - idletime);
 			}
 		}
@@ -193,9 +193,10 @@ void scr_time( struct code *pc, int fargc, char **fargv )
 	else if (!strcasecmp(pc->inst->name, "whenami"))
 	{
 		struct tm *tt;
-
+		
 		tt=localtime(&now);
-		strftime(value, MAXTEXTLENGTH-1, "%H:%M", tt);
+		value=malloc(10);
+		strftime(value, 9, "%H:%M", tt);
 	}
 	else if (!strcasecmp(pc->inst->name, "date"))
 	{
@@ -963,16 +964,16 @@ void scr_split( struct code *pc, int fargc, char **fargv )
 		char *bbp;
 		if ((bbp = strchr(ccp, ' ')) == NULL)
 		{
-			VAR_STR_UPDATE(&var1, cc);
+			VAR_STR_UPDATE(&var1, ccp);
 			VAR_STR_UPDATE(&var2, "");
 		}
 		else
 		{
-			bbp = bb;
-			bbp++;
-			VAR_STR_UPDATE(&var2, bbp);
-			*bb=0;
-			VAR_STR_UPDATE(&var1, cc);
+			char *dd = bbp;
+			dd++;
+			VAR_STR_UPDATE(&var2, dd);
+			*bbp=0;
+			VAR_STR_UPDATE(&var1, ccp);
 		}
 	}
 



View it on GitLab: https://projects.sucs.org/arthur/mw/compare/f4da16559917ccb5aa04be66edbd4521fb8ffbd6...b756151260266a14a023876ea40b0e51f24a71f2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20151029/ff5c6694/attachment.html>


More information about the mw-devel mailing list