]> git.sesse.net Git - vlc/blobdiff - plugins/mpeg_system/input_es.c
* Fixed a segfault at EOF in input_es.c and input_ts.c (when i_read == 0).
[vlc] / plugins / mpeg_system / input_es.c
index afa78ed3ea9600a6004d22cc65b894e38a61f749..700a61e82e1996bc2a41bd2f44b748b24cd795cf 100644 (file)
@@ -2,7 +2,7 @@
  * input_es.c: Elementary Stream demux and packet management
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: input_es.c,v 1.9 2001/12/29 03:07:51 massiot Exp $
+ * $Id: input_es.c,v 1.10 2001/12/30 04:26:53 sam Exp $
  *
  * Author: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -222,15 +222,13 @@ static int ESRead( input_thread_t * p_input,
          * back to the buffer allocator. */
         int i_loop;
 
-        for( i_loop = 0; i_loop + 1 < i_read; i_loop++ )
+        for( i_loop = 0; i_loop < i_read; i_loop++ )
         {
-            p_data = p_data->p_next;
-        }
-        p_input->pf_delete_packet( p_input->p_method_data, p_data->p_next );
-        if( i_read != 0 )
-        {
-            p_data->p_next = NULL;
+            pp_data = &(*pp_data)->p_next;
         }
+
+        p_input->pf_delete_packet( p_input->p_method_data, *pp_data );
+        *pp_data = NULL;
     }
 
     return( i_read );