From: divverent Date: Thu, 15 Nov 2007 15:07:16 +0000 (+0000) Subject: fix tempstring allocation bug in VM_tokenize* X-Git-Tag: xonotic-v0.1.0preview~2783 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=46023d61855b8e3b0537e091951360d72d70eb80;p=xonotic%2Fdarkplaces.git fix tempstring allocation bug in VM_tokenize* git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7698 d7cf8633-e32d-0410-b094-e92efae38249 --- 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++)