[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: playlist_controller: fix path leak

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Jan 13 08:06:07 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
f48fd358 by Johannes Kauffmann at 2024-01-13T07:40:24+00:00
qt: playlist_controller: fix path leak

Also free the pointer when returning in case the path is not a
directory (this error condition was added later). To make sure this leak
does not resurface, use vlc::wrap_cptr.

Fixes: 73f7b186190ecf5811594b16c7eac4520159ef2d

- - - - -
346113b3 by Johannes Kauffmann at 2024-01-13T07:40:24+00:00
qt: playlist_controller: fix uri leak

As it stands, uri (result of input_item_GetURI()) is leaked when:
- path is NULL
- containingDir is not a dir
- file is not a local file
- none of the early returns are taken but uri is not NULL or empty

To tackle these all at once, use vlc::wrap_cptr.

Fixes: 1b95adaae51970753c10d929e9dba695ab6cfbbe

- - - - -


1 changed file:

- modules/gui/qt/playlist/playlist_controller.cpp


Changes:

=====================================
modules/gui/qt/playlist/playlist_controller.cpp
=====================================
@@ -514,22 +514,20 @@ void PlaylistController::explore(const PlaylistItem& pItem)
     if( playlistItem )
     {
         input_item_t * const p_input = vlc_playlist_item_GetMedia(playlistItem);
-        char * const uri = input_item_GetURI(p_input);
+        auto uri = vlc::wrap_cptr( input_item_GetURI(p_input) );
 
-        if( uri && uri[0] != '\0')
+        if( uri && uri.get()[0] != '\0')
         {
-            char * const path = vlc_uri2path( uri );
+            auto path = vlc::wrap_cptr( vlc_uri2path( uri.get() ) );
 
             if( !path )
                 return;
 
-            QString containingDir = QFileInfo( path ).absolutePath();
+            QString containingDir = QFileInfo( path.get() ).absolutePath();
             if( !QFileInfo( containingDir ).isDir() )
                 return;
 
             QUrl file = QUrl::fromLocalFile( containingDir );
-            free( path );
-
             if( !file.isLocalFile() )
                 return;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/66204d9244a96a03569492ec40262e20cb2b03f6...346113b36b5ff643a886c1b59c14a00ada39ce02

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/66204d9244a96a03569492ec40262e20cb2b03f6...346113b36b5ff643a886c1b59c14a00ada39ce02
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list