]> git.sesse.net Git - vlc/commitdiff
* include/aout_internal.h: fixed old memory leak when alloca() isn't available.
authorGildas Bazin <gbazin@videolan.org>
Fri, 7 Jan 2005 09:54:01 +0000 (09:54 +0000)
committerGildas Bazin <gbazin@videolan.org>
Fri, 7 Jan 2005 09:54:01 +0000 (09:54 +0000)
include/aout_internal.h

index 5a1678701a9ce773c9540f2993cca042441adf35..c1ba1d42db984cd04df0abf4fdc2aebe3d53a7c1 100644 (file)
@@ -39,6 +39,7 @@ typedef struct aout_alloc_t
         if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK )                  \
         {                                                                   \
             (p_new_buffer) = alloca( i_alloc_size + sizeof(aout_buffer_t) );\
+            i_alloc_type = AOUT_ALLOC_STACK;                                \
         }                                                                   \
         else
 #else
@@ -53,16 +54,17 @@ typedef struct aout_alloc_t
     }                                                                       \
     else                                                                    \
     {                                                                       \
-        int i_alloc_size;                                                   \
+        int i_alloc_size, i_alloc_type;                                     \
         i_alloc_size = (int)( (uint64_t)(p_alloc)->i_bytes_per_sec          \
                                             * (i_nb_usec) / 1000000 + 1 );  \
         ALLOCA_TEST( p_alloc, p_new_buffer )                                \
         {                                                                   \
             (p_new_buffer) = malloc( i_alloc_size + sizeof(aout_buffer_t) );\
+            i_alloc_type = AOUT_ALLOC_HEAP;                                 \
         }                                                                   \
         if ( p_new_buffer != NULL )                                         \
         {                                                                   \
-            (p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type;         \
+            (p_new_buffer)->i_alloc_type = i_alloc_type;                    \
             (p_new_buffer)->i_size = i_alloc_size;                          \
             (p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer)             \
                                          + sizeof(aout_buffer_t);           \