From 46023d61855b8e3b0537e091951360d72d70eb80 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 15 Nov 2007 15:07:16 +0000 Subject: [PATCH] fix tempstring allocation bug in VM_tokenize* git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7698 d7cf8633-e32d-0410-b094-e92efae38249 --- prvm_cmds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/prvm_cmds.c b/prvm_cmds.c index 73d36bca..e0ec50e2 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -2076,10 +2076,12 @@ int tokens[256]; void VM_tokenize (void) { const char *p; + static char string[VM_STRINGTEMP_LENGTH]; // static, because it's big VM_SAFEPARMCOUNT(1,VM_tokenize); - p = PRVM_G_STRING(OFS_PARM0); + strlcpy(string, PRVM_G_STRING(OFS_PARM0), sizeof(string)); + p = string; num_tokens = 0; while(COM_ParseToken_VM_Tokenize(&p, false)) @@ -2115,10 +2117,12 @@ void VM_tokenizebyseparator (void) const char *p; const char *token; char tokentext[MAX_INPUTLINE]; + static char string[VM_STRINGTEMP_LENGTH]; // static, because it's big VM_SAFEPARMCOUNTRANGE(2, 8,VM_tokenizebyseparator); - p = PRVM_G_STRING(OFS_PARM0); + strlcpy(string, PRVM_G_STRING(OFS_PARM0), sizeof(string)); + p = string; numseparators = 0;; for (j = 1;j < prog->argc;j++) -- 2.39.2