]> git.sesse.net Git - vlc/blobdiff - modules/control/http/util.c
Remove COMPILE_DOMAIN, merge into COMPILE_HOST
[vlc] / modules / control / http / util.c
index 1226002e20904a1697114694f1c06c2a9d1bed4a..7134321be87ac7ae805ed75d2c520d076aa7ac0a 100644 (file)
@@ -30,6 +30,9 @@
 #include <vlc_common.h>
 #include "http.h"
 #include <vlc_strings.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
 
 /****************************************************************************
  * File and directory functions
@@ -90,11 +93,12 @@ int FileLoad( FILE *f, char **pp_data, int *pi_data )
 
     /* just load the file */
     *pi_data = 0;
-    *pp_data = malloc( 1025 );  /* +1 for \0 */
+    *pp_data = xmalloc( 1025 );  /* +1 for \0 */
+
     while( ( i_read = fread( &(*pp_data)[*pi_data], 1, 1024, f ) ) == 1024 )
     {
         *pi_data += 1024;
-        *pp_data = realloc( *pp_data, *pi_data  + 1025 );
+        *pp_data = xrealloc( *pp_data, *pi_data  + 1025 );
     }
     if( i_read > 0 )
     {
@@ -232,7 +236,7 @@ int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
             }
             if( f == NULL )
             {
-                f = malloc( sizeof( httpd_file_sys_t ) );
+                f = xmalloc( sizeof( httpd_file_sys_t ) );
                 f->b_handler = false;
             }
 
@@ -920,7 +924,7 @@ char *RealPath( const char *psz_src )
     char *p;
     int i_len = strlen(psz_src);
 
-    psz_dir = malloc( i_len + 2 );
+    psz_dir = xmalloc( i_len + 2 );
     strcpy( psz_dir, psz_src );
 
     /* Add a trailing sep to ease the .. step */
@@ -952,10 +956,12 @@ char *RealPath( const char *psz_src )
     if( psz_dir[0] == '~' )
     {
         char *home = config_GetUserDir( VLC_HOME_DIR ), *dir;
-        asprintf( &dir, "%s%s", home, psz_dir + 1 );
-        free( psz_dir );
+        if( asprintf( &dir, "%s%s", home, psz_dir + 1 ) != -1 )
+        {
+            free( psz_dir );
+            psz_dir = dir;
+        }
         free( home );
-        psz_dir = dir;
     }
 
     if( strlen(psz_dir) > 2 )