]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
control http: fix memleak.
[vlc] / modules / control / http / http.c
index 17377229f40be4fe9ae91d7d5362e7fc5239ec43..54cce0bfa75cf51f11920d5c6d144427833f741e 100644 (file)
@@ -2,7 +2,6 @@
  * http.c : HTTP/HTTPS Remote control interface
  *****************************************************************************
  * Copyright (C) 2001-2006 the VideoLAN team
- * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Laurent Aimar <fenrir@via.ecp.fr>
@@ -29,6 +28,8 @@
 #include "http.h"
 #include <vlc_plugin.h>
 
+#include <assert.h>
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -63,8 +64,8 @@ static void Close( vlc_object_t * );
 #define CRL_LONGTEXT N_( "HTTP interace Certificates Revocation List file." )
 
 vlc_module_begin();
-    set_shortname( _("HTTP"));
-    set_description( _("HTTP remote control interface") );
+    set_shortname( N_("HTTP"));
+    set_description( N_("HTTP remote control interface") );
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_MAIN );
         add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, true );
@@ -100,9 +101,6 @@ int  ArtCallback( httpd_handler_sys_t *p_args,
 #if !defined(__APPLE__) && !defined(SYS_BEOS) && !defined(WIN32)
 static int DirectoryCheck( const char *psz_dir )
 {
-    DIR           *p_dir;
-
-#ifdef HAVE_SYS_STAT_H
     struct stat   stat_info;
 
     if( ( utf8_stat( psz_dir, &stat_info ) == -1 )
@@ -110,14 +108,6 @@ static int DirectoryCheck( const char *psz_dir )
     {
         return VLC_EGENERIC;
     }
-#endif
-
-    if( ( p_dir = utf8_opendir( psz_dir ) ) == NULL )
-    {
-        return VLC_EGENERIC;
-    }
-    closedir( p_dir );
-
     return VLC_SUCCESS;
 }
 #endif
@@ -131,7 +121,7 @@ static int Open( vlc_object_t *p_this )
     intf_thread_t *p_intf = (intf_thread_t*)p_this;
     intf_sys_t    *p_sys;
     char          *psz_address;
-    const char    *psz_cert = NULL, *psz_key = NULL, *psz_ca = NULL,
+    char          *psz_cert = NULL, *psz_key = NULL, *psz_ca = NULL,
                   *psz_crl = NULL;
     int           i_port       = 0;
     char          *psz_src = NULL;
@@ -229,6 +219,11 @@ static int Open( vlc_object_t *p_this )
     p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_intf), psz_address,
                                             i_port, psz_cert, psz_key, psz_ca,
                                             psz_crl );
+    free( psz_cert );
+    free( psz_key );
+    free( psz_ca );
+    free( psz_crl );
+
     if( p_sys->p_httpd_host == NULL )
     {
         msg_Err( p_intf, "cannot listen on %s:%d", psz_address, i_port );
@@ -347,13 +342,12 @@ static void Close ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
     intf_sys_t    *p_sys = p_intf->p_sys;
-
     int i;
 
+#ifdef ENABLE_VLM
     if( p_sys->p_vlm )
-    {
         vlm_Delete( p_sys->p_vlm );
-    }
+#endif
     for( i = 0; i < p_sys->i_files; i++ )
     {
         if( p_sys->pp_files[i]->b_handler )
@@ -610,7 +604,7 @@ int  HandlerCallback( httpd_handler_sys_t *p_args,
     char *p_url = (char *)_p_url;
     char *p_request = (char *)_p_request;
     char **pp_data = (char **)_pp_data;
-    char *p_in = (char *)p_in;
+    char *p_in = (char *)_p_in;
     int i_request = p_request != NULL ? strlen( p_request ) : 0;
     char *p;
     int i_env = 0;