]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_cmds.c
Cleaned up alot more memory leaks. (still get 720 leaks just running demo1.dem)
[xonotic/darkplaces.git] / pr_cmds.c
index 6de3550b3db8e95d3f9ba68a74abb5e54a024ce7..e7289720460ac58696c2fda7b01e841a41f342f2 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -2789,7 +2789,7 @@ void PF_stof(void)
 //float(string filename, float mode) fopen = #110; // opens a file inside quake/gamedir/data/ (mode is FILE_READ, FILE_APPEND, or FILE_WRITE), returns fhandle >= 0 if successful, or fhandle < 0 if unable to open file for any reason
 void PF_fopen(void)
 {
-       int filenum, mode, i;
+       int filenum, mode;
        char *modestring, *filename;
        for (filenum = 0;filenum < MAX_PRFILES;filenum++)
                if (pr_files[filenum] == NULL)
@@ -2818,21 +2818,7 @@ void PF_fopen(void)
                return;
        }
        filename = G_STRING(OFS_PARM0);
-       // control characters do not cause issues with any platforms I know of, but they are usually annoying to deal with
-       // ../ is parent directory on many platforms
-       // // is parent directory on Amiga
-       // / at the beginning of a path is root on unix, and parent directory on Amiga
-       // : is root of drive on Amiga (also used as a directory separator on Mac, but / works there too, so that's a bad idea)
-       // \ is a windows-ism (so it's naughty to use it, / works on all platforms)
-       for (i = 0;filename[i];i++)
-       {
-               if (filename[i] < ' ' || (filename[i] == '/' && filename[i+1] == '/') || (filename[i] == '.' && filename[i+1] == '.') || filename[i] == ':' || filename[i] == '\\' || filename[0] == '/')
-               {
-                       Con_Printf("PF_fopen: dangerous/confusing/annoying/non-portable filename \"%s\" not allowed. (contains control characters or // or .. or : or \\ or begins with /)\n", filename);
-                       G_FLOAT(OFS_RETURN) = -4;
-                       return;
-               }
-       }
+       // -4 failure (dangerous/non-portable filename) removed, FS_Open checks
        pr_files[filenum] = FS_Open(va("data/%s", filename), modestring, false);
 
        if (pr_files[filenum] == NULL && modestring == "rb")
@@ -3756,6 +3742,11 @@ void PR_Cmd_Init(void)
        PR_Search_Init();
 }
 
+void PR_Cmd_Shutdown(void)
+{
+       Mem_FreePool (&pr_strings_mempool);
+}
+
 void PR_Cmd_Reset(void)
 {
        Mem_EmptyPool(pr_strings_mempool);