]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix tempstring allocation bug in VM_tokenize*
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 15 Nov 2007 15:07:16 +0000 (15:07 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 15 Nov 2007 15:07:16 +0000 (15:07 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7698 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c

index 73d36bca1fd8b831192b60586aeb58ed86b25edb..e0ec50e20957a3d74bd8f04f9625f5b688cdce5c 100644 (file)
@@ -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++)