python bindings : fix pyoptions_to_args and a memleak in the same time
authorRafaël Carré <funman@videolan.org>
Tue, 25 Mar 2008 09:53:13 +0000 (10:53 +0100)
committerRafaël Carré <funman@videolan.org>
Tue, 25 Mar 2008 09:53:13 +0000 (10:53 +0100)
bindings/python/vlc_instance.c

index 332eb26..a9228dd 100644 (file)
@@ -28,9 +28,6 @@ pyoptions_to_args(PyObject *py_options, char*** pppsz_args)
 {
     Py_ssize_t i_size;
     Py_ssize_t  i_index;
 {
     Py_ssize_t i_size;
     Py_ssize_t  i_index;
-    char** ppsz_args = *pppsz_args;
-    ppsz_args = NULL;
 
     Py_INCREF( py_options );
     if( ! PySequence_Check( py_options ) )
 
     Py_INCREF( py_options );
     if( ! PySequence_Check( py_options ) )
@@ -39,7 +36,9 @@ pyoptions_to_args(PyObject *py_options, char*** pppsz_args)
         return -1;
     }
     i_size = PySequence_Size( py_options );
         return -1;
     }
     i_size = PySequence_Size( py_options );
-    ppsz_args = malloc( ( i_size + 1 ) * sizeof( char * ) );
+
+    char **ppsz_args = *pppsz_args = malloc( ( i_size + 1 ) * sizeof( char * ) );
+
     if( ! ppsz_args )
     {
         PyErr_SetString( PyExc_MemoryError, "Out of memory" );
     if( ! ppsz_args )
     {
         PyErr_SetString( PyExc_MemoryError, "Out of memory" );