]> git.sesse.net Git - vlc/blobdiff - modules/access/directory.c
Do not use (input_thread_t*)p_access->p_parent it is not always true.
[vlc] / modules / access / directory.c
index 832cb6c5cb1fed92509789a6170761239c735dab..4311edc1b2d55d9794f7d44e58e0c93331eb66cc 100644 (file)
@@ -195,22 +195,32 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
         return VLC_ENOMEM;
 
     playlist_t         *p_playlist = pl_Yield( p_access );
+    input_thread_t     *p_input = (input_thread_t*)vlc_object_find( p_access, VLC_OBJECT_INPUT, FIND_PARENT );
+
     playlist_item_t    *p_item_in_category;
-    input_item_t       *p_current_input = input_GetItem(
-                                    (input_thread_t*)p_access->p_parent);
-    playlist_item_t    *p_current = playlist_ItemGetByInput( p_playlist,
-                                                             p_current_input,
-                                                             VLC_FALSE );
+    input_item_t       *p_current_input;
+    playlist_item_t    *p_current;
+
+    if( !p_input )
+    {
+        msg_Err( p_access, "unable to find input (internal error)" );
+        vlc_object_release( p_playlist );
+        return VLC_ENOOBJ;
+    }
+
+    p_current_input = input_GetItem( p_input );
+    p_current = playlist_ItemGetByInput( p_playlist, p_current_input, VLC_FALSE );
 
-    if( p_current == NULL )
+    if( !p_current )
     {
         msg_Err( p_access, "unable to find item in playlist" );
+        vlc_object_release( p_input );
         vlc_object_release( p_playlist );
         return VLC_ENOOBJ;
     }
 
     /* Remove the ending '/' char */
-    if (psz_name[0])
+    if( psz_name[0] )
     {
         char *ptr = psz_name + strlen (psz_name);
         switch (*--ptr)
@@ -249,6 +259,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
     playlist_Signal( p_playlist );
 
     if( psz_name ) free( psz_name );
+    vlc_object_release( p_input );
     vlc_object_release( p_playlist );
 
     /* Return fake data forever */