]> git.sesse.net Git - vlc/commitdiff
Fix malloc error handling
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 5 Aug 2007 08:27:54 +0000 (08:27 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 5 Aug 2007 08:27:54 +0000 (08:27 +0000)
(bug reported by David Thiel)

src/audio_output/dec.c

index 5ba82c316406327bac5c755e42e4c6cd27406da0..cf9313e7b7a9107590b07da291d2f2efc6d4a235 100644 (file)
@@ -280,24 +280,20 @@ aout_buffer_t * aout_DecNewBuffer( aout_instance_t * p_aout,
 
     /* This necessarily allocates in the heap. */
     aout_BufferAlloc( &p_input->input_alloc, duration, NULL, p_buffer );
-    p_buffer->i_nb_samples = i_nb_samples;
-    p_buffer->i_nb_bytes = i_nb_samples * p_input->input.i_bytes_per_frame
-                              / p_input->input.i_frame_length;
+    if( p_buffer != NULL )
+        p_buffer->i_nb_bytes = i_nb_samples * p_input->input.i_bytes_per_frame
+                                  / p_input->input.i_frame_length;
 
     /* Suppose the decoder doesn't have more than one buffered buffer */
     p_input->b_changed = 0;
 
     vlc_mutex_unlock( &p_input->lock );
 
-    if ( p_buffer == NULL )
-    {
-        msg_Err( p_aout, "NULL buffer !" );
-    }
-    else
-    {
-        p_buffer->start_date = p_buffer->end_date = 0;
-    }
+    if( p_buffer == NULL )
+        return NULL;
 
+    p_buffer->i_nb_samples = i_nb_samples;
+    p_buffer->start_date = p_buffer->end_date = 0;
     return p_buffer;
 }