]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/common/vfs.c
q3map2: better use strncpy instead of strcpy
[xonotic/netradiant.git] / tools / quake3 / common / vfs.c
index 16a78289817b017de067257c6690ada8feed61b8..8f5e57bfb9a1bb0dcfbe4068478eda2520fa6ea9 100644 (file)
@@ -50,7 +50,7 @@
 #include "mathlib.h"
 #include "inout.h"
 #include "vfs.h"
-#include <minizip/unzip.h>
+#include <unzip.h>
 #include <glib.h>
 
 typedef struct
@@ -229,6 +229,7 @@ void vfsInitDirectory( const char *path ){
 
                                        if ( ext != NULL && ( !Q_stricmp( ext, ".pk3dir" ) || !Q_stricmp( ext, ".dpkdir" ) ) ) {
                                                if ( g_numDirs == VFS_MAXDIRS ) {
+                                                       g_free( dirlist );
                                                        continue;
                                                }
                                                snprintf( g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name );
@@ -239,6 +240,7 @@ void vfsInitDirectory( const char *path ){
                                        }
 
                                        if ( ext == NULL || ( Q_stricmp( ext, ".pk3" ) != 0 && Q_stricmp( ext, ".dpk" ) != 0 ) ) {
+                                               g_free( dirlist );
                                                continue;
                                        }
                                }
@@ -342,7 +344,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
        }
 
        *bufferptr = NULL;
-       strcpy( fixed, filename );
+       strncpy( fixed, filename, sizeof( fixed ) );
        vfsFixDOSName( fixed );
        lower = g_ascii_strdown( fixed, -1 );
 
@@ -410,6 +412,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
                        i = unzReadCurrentFile( file->zipfile, *bufferptr, file->size );
                        unzCloseCurrentFile( file->zipfile );
                        if ( i < 0 ) {
+                               g_free( lower );
                                return -1;
                        }
                        else{