[vlc-commits] [Git][videolan/vlc][master] 11 commits: file: fix handling of NULL config_GetUserDir() value
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Sep 2 08:24:37 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
e9e85242 by Steve Lhomme at 2022-09-02T07:53:46+00:00
file: fix handling of NULL config_GetUserDir() value
- - - - -
e6713460 by Steve Lhomme at 2022-09-02T07:53:46+00:00
preparser: fix usage of NULL config_GetUserDir results
- - - - -
23890bbf by Steve Lhomme at 2022-09-02T07:53:46+00:00
medialibrary: fix usage of NULL config_GetUserDir result
- - - - -
7800ddaa by Steve Lhomme at 2022-09-02T07:53:46+00:00
cdda: fix usage of NULL config_GetUserDir result
- - - - -
df1ee8c9 by Steve Lhomme at 2022-09-02T07:53:46+00:00
sftp: fix usage of NULL config_GetUserDir result
- - - - -
15b00a88 by Steve Lhomme at 2022-09-02T07:53:46+00:00
qt: servicesdiscoverymodel: fix usage of NULL config_GetUserDir result
And fix leak
- - - - -
a8e3b87d by Steve Lhomme at 2022-09-02T07:53:46+00:00
qt: player_controller: fix usage of NULL config_GetUserDir result
- - - - -
663af15a by Steve Lhomme at 2022-09-02T07:53:46+00:00
qt: fix usage of NULL config_GetUserDir result
- - - - -
9960c105 by Steve Lhomme at 2022-09-02T07:53:46+00:00
skins2: fix usage of NULL config_GetUserDir/config_GetSysPath results
- - - - -
cfc1bc92 by Steve Lhomme at 2022-09-02T07:53:46+00:00
lua: fix usage of NULL config_GetUserDir/config_GetSysPath results
- - - - -
250e0193 by Steve Lhomme at 2022-09-02T07:53:46+00:00
video_filter: scene: fix usage when config_GetUserDir returns NULL
The snapshot cannot be created so the filter cannot be used.
- - - - -
13 changed files:
- modules/access/cdda.c
- modules/access/sftp.c
- modules/gui/qt/network/servicesdiscoverymodel.cpp
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/qt.cpp
- modules/gui/skins2/os2/os2_factory.cpp
- modules/gui/skins2/win32/win32_factory.cpp
- modules/gui/skins2/x11/x11_factory.cpp
- modules/lua/vlc.c
- modules/misc/medialibrary/medialibrary.cpp
- modules/video_filter/scene.c
- src/config/file.c
- src/preparser/art.c
Changes:
=====================================
modules/access/cdda.c
=====================================
@@ -551,13 +551,15 @@ static cddb_disc_t *GetCDDBInfo( vlc_object_t *obj, const vcddev_toc_t *p_toc )
char *psz_cachedir;
char *psz_temp = config_GetUserDir( VLC_CACHE_DIR );
-
- if( asprintf( &psz_cachedir, "%s" DIR_SEP "cddb", psz_temp ) > 0 ) {
- cddb_cache_enable( p_cddb );
- cddb_cache_set_dir( p_cddb, psz_cachedir );
- free( psz_cachedir );
+ if (likely(psz_temp != NULL))
+ {
+ if( asprintf( &psz_cachedir, "%s" DIR_SEP "cddb", psz_temp ) > 0 ) {
+ cddb_cache_enable( p_cddb );
+ cddb_cache_set_dir( p_cddb, psz_cachedir );
+ free( psz_cachedir );
+ }
+ free( psz_temp );
}
- free( psz_temp );
cddb_set_timeout( p_cddb, 10 );
=====================================
modules/access/sftp.c
=====================================
@@ -324,13 +324,17 @@ static int Open( vlc_object_t* p_this )
goto error;
psz_home = config_GetUserDir( VLC_HOME_DIR );
- char *psz_knownhosts_file;
- if( asprintf( &psz_knownhosts_file, "%s/.ssh/known_hosts", psz_home ) != -1 )
+ if (likely(psz_home != NULL))
{
- if( libssh2_knownhost_readfile( ssh_knownhosts, psz_knownhosts_file,
- LIBSSH2_KNOWNHOST_FILE_OPENSSH ) < 0 )
- msg_Err( p_access, "Failure reading known_hosts '%s'", psz_knownhosts_file );
- free( psz_knownhosts_file );
+ char *psz_knownhosts_file;
+ if( asprintf( &psz_knownhosts_file, "%s/.ssh/known_hosts", psz_home ) != -1 )
+ {
+ if( libssh2_knownhost_readfile( ssh_knownhosts, psz_knownhosts_file,
+ LIBSSH2_KNOWNHOST_FILE_OPENSSH ) < 0 )
+ msg_Err( p_access, "Failure reading known_hosts '%s'", psz_knownhosts_file );
+ free( psz_knownhosts_file );
+ }
+ free( psz_home );
}
const char *fingerprint = libssh2_session_hostkey( p_sys->ssh_session, &i_len, &i_type );
@@ -558,7 +562,6 @@ static int Open( vlc_object_t* p_this )
i_result = VLC_SUCCESS;
error:
- free( psz_home );
free( psz_session_username );
free( psz_path );
vlc_credential_clean( &credential );
=====================================
modules/gui/qt/network/servicesdiscoverymodel.cpp
=====================================
@@ -235,25 +235,30 @@ ServicesDiscoveryModel::Item &ServicesDiscoveryModel::Item::operator=( ServicesD
entry = addon;
if ( addon->psz_image_data ) {
- QDir dir( config_GetUserDir( VLC_CACHE_DIR ) );
- dir.mkdir("art");
- dir.cd("art");
- dir.mkdir("qt-addon-covers");
- dir.cd("qt-addon-covers");
-
- QString id = addons_uuid_to_psz( &addon->uuid );
- QString filename = QString("addon_thumbnail_%1.png").arg(id);
- QString absoluteFilePath = dir.absoluteFilePath(filename);
-
- if ( !QFileInfo::exists( absoluteFilePath )) {
- QPixmap pixmap;
- pixmap.loadFromData( QByteArray::fromBase64( QByteArray( addon->psz_image_data ) ),
- 0,
- Qt::AutoColor
- );
- pixmap.save(absoluteFilePath);
+ char *cDir = config_GetUserDir( VLC_CACHE_DIR );
+ if (likely(cDir != nullptr))
+ {
+ QDir dir( cDir );
+ free(cDir);
+ dir.mkdir("art");
+ dir.cd("art");
+ dir.mkdir("qt-addon-covers");
+ dir.cd("qt-addon-covers");
+
+ QString id = addons_uuid_to_psz( &addon->uuid );
+ QString filename = QString("addon_thumbnail_%1.png").arg(id);
+ QString absoluteFilePath = dir.absoluteFilePath(filename);
+
+ if ( !QFileInfo::exists( absoluteFilePath )) {
+ QPixmap pixmap;
+ pixmap.loadFromData( QByteArray::fromBase64( QByteArray( addon->psz_image_data ) ),
+ 0,
+ Qt::AutoColor
+ );
+ pixmap.save(absoluteFilePath);
+ }
+ artworkUrl = QUrl::fromLocalFile( absoluteFilePath );
}
- artworkUrl = QUrl::fromLocalFile( absoluteFilePath );
}
else if ( addon->e_flags & ADDON_BROKEN )
artworkUrl = QUrl( ":/addons/addon_broken.svg" );
=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -1880,7 +1880,7 @@ void PlayerController::setArt( input_item_t *p_item, QString fileUrl )
QString old_url = decodeArtURL( p_item );
old_url = QDir( old_url ).canonicalPath();
- if( old_url.startsWith( QString::fromUtf8( psz_cachedir ) ) )
+ if( psz_cachedir != nullptr && old_url.startsWith( QString::fromUtf8( psz_cachedir ) ) )
QFile( old_url ).remove(); /* Purge cached artwork */
free( psz_cachedir );
=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -726,11 +726,14 @@ static void *Thread( void *obj )
/* All the settings are in the .conf/.ini style */
#ifdef _WIN32
char *cConfigDir = config_GetUserDir( VLC_CONFIG_DIR );
- QString configDir = cConfigDir;
- free( cConfigDir );
- if( configDir.endsWith( "\\vlc" ) )
- configDir.chop( 4 ); /* the "\vlc" dir is added again by QSettings */
- QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, configDir );
+ if (likely(cConfigDir != nullptr))
+ {
+ QString configDir = cConfigDir;
+ free( cConfigDir );
+ if( configDir.endsWith( "\\vlc" ) )
+ configDir.chop( 4 ); /* the "\vlc" dir is added again by QSettings */
+ QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, configDir );
+ }
#endif
p_intf->mainSettings = new QSettings(
=====================================
modules/gui/skins2/os2/os2_factory.cpp
=====================================
@@ -218,16 +218,22 @@ bool OS2Factory::init()
// Initialize the resource path
char *datadir = config_GetUserDir( VLC_USERDATA_DIR );
- m_resourcePath.push_back( (std::string)datadir + "\\skins" );
- free( datadir );
+ if (likely(datadir != nullptr))
+ {
+ m_resourcePath.push_back( (std::string)datadir + "\\skins" );
+ free( datadir );
+ }
datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
- m_resourcePath.push_back( (std::string)datadir + "\\skins" );
- m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
- m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
- m_resourcePath.push_back( (std::string)datadir + "\\share\\skins2" );
- m_resourcePath.push_back( (std::string)datadir + "\\vlc\\skins" );
- m_resourcePath.push_back( (std::string)datadir + "\\vlc\\skins2" );
- free( datadir );
+ if (likely(datadir != nullptr))
+ {
+ m_resourcePath.push_back( (std::string)datadir + "\\skins" );
+ m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
+ m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
+ m_resourcePath.push_back( (std::string)datadir + "\\share\\skins2" );
+ m_resourcePath.push_back( (std::string)datadir + "\\vlc\\skins" );
+ m_resourcePath.push_back( (std::string)datadir + "\\vlc\\skins2" );
+ free( datadir );
+ }
// All went well
return true;
=====================================
modules/gui/skins2/win32/win32_factory.cpp
=====================================
@@ -232,14 +232,20 @@ bool Win32Factory::init()
// Initialize the resource path
char *datadir = config_GetUserDir( VLC_USERDATA_DIR );
- m_resourcePath.push_back( (std::string)datadir + "\\skins" );
- free( datadir );
+ if (likely(datadir != nullptr))
+ {
+ m_resourcePath.push_back( (std::string)datadir + "\\skins" );
+ free( datadir );
+ }
datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
- m_resourcePath.push_back( (std::string)datadir + "\\skins" );
- m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
- m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
- m_resourcePath.push_back( (std::string)datadir + "\\share\\skins2" );
- free( datadir );
+ if (likely(datadir != nullptr))
+ {
+ m_resourcePath.push_back( (std::string)datadir + "\\skins" );
+ m_resourcePath.push_back( (std::string)datadir + "\\skins2" );
+ m_resourcePath.push_back( (std::string)datadir + "\\share\\skins" );
+ m_resourcePath.push_back( (std::string)datadir + "\\share\\skins2" );
+ free( datadir );
+ }
// Enumerate all monitors available
EnumDisplayMonitors( NULL, NULL, MonitorEnumProc, (LPARAM)&m_monitorList );
=====================================
modules/gui/skins2/x11/x11_factory.cpp
=====================================
@@ -85,12 +85,18 @@ bool X11Factory::init()
// Initialize the resource path
char *datadir = config_GetUserDir( VLC_USERDATA_DIR );
- m_resourcePath.push_back( (std::string)datadir + "/skins2" );
- free( datadir );
+ if (likely(datadir != nullptr))
+ {
+ m_resourcePath.push_back( (std::string)datadir + "/skins2" );
+ free( datadir );
+ }
m_resourcePath.push_back( (std::string)"share/skins2" );
datadir = config_GetSysPath(VLC_PKG_DATA_DIR, "skins2");
- m_resourcePath.push_back( (std::string)datadir );
- free( datadir );
+ if (likely(datadir != nullptr))
+ {
+ m_resourcePath.push_back( (std::string)datadir );
+ free( datadir );
+ }
// Determine the monitor geometry
getDefaultGeometry( &m_screenWidth, &m_screenHeight );
=====================================
modules/lua/vlc.c
=====================================
@@ -199,15 +199,17 @@ int vlclua_dir_list(const char *luadirname, char ***restrict listp)
*listp = list;
/* Lua scripts in user-specific data directory */
- list = vlclua_dir_list_append(list, config_GetUserDir(VLC_USERDATA_DIR),
- luadirname);
+ char *userdir = config_GetUserDir(VLC_USERDATA_DIR);
+ if (likely(userdir != NULL))
+ list = vlclua_dir_list_append(list, userdir, luadirname);
char *libdir = config_GetSysPath(VLC_PKG_LIBEXEC_DIR, NULL);
char *datadir = config_GetSysPath(VLC_PKG_DATA_DIR, NULL);
bool both = libdir != NULL && datadir != NULL && strcmp(libdir, datadir);
/* Tokenized Lua scripts in architecture-specific data directory */
- list = vlclua_dir_list_append(list, libdir, luadirname);
+ if (libdir != NULL)
+ list = vlclua_dir_list_append(list, libdir, luadirname);
/* Source Lua Scripts in architecture-independent data directory */
if (both || libdir == NULL)
=====================================
modules/misc/medialibrary/medialibrary.cpp
=====================================
@@ -395,7 +395,10 @@ void MediaLibrary::onRescanStarted()
MediaLibrary* MediaLibrary::create( vlc_medialibrary_module_t* vlc_ml )
{
- auto userDir = vlc::wrap_cptr( config_GetUserDir( VLC_USERDATA_DIR ) );
+ char *userdir = config_GetUserDir( VLC_USERDATA_DIR );
+ if (unlikely(userdir == nullptr))
+ return nullptr;
+ auto userDir = vlc::wrap_cptr( userdir );
auto mlDir = std::string{ userDir.get() } + "/ml/";
auto dbPath = mlDir + "ml.db";
auto mlFolderPath = mlDir + "mlstorage/";
=====================================
modules/video_filter/scene.c
=====================================
@@ -194,6 +194,16 @@ static int Create( filter_t *p_filter )
if( p_sys->psz_path == NULL )
p_sys->psz_path = config_GetUserDir( VLC_PICTURES_DIR );
+ if (unlikely(p_sys->psz_path == NULL))
+ {
+ msg_Err( p_filter, "could not create snapshot: no directory" );
+ image_HandlerDelete( p_sys->p_image );
+ free( p_sys->psz_prefix );
+ free( p_sys->psz_format );
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
+
static const struct vlc_filter_operations filter_ops =
{
.filter_video = Filter, .close = Destroy,
=====================================
src/config/file.c
=====================================
@@ -58,6 +58,8 @@ static char *config_GetConfigFile( libvlc_int_t *obj )
if( psz_file == NULL )
{
char *psz_dir = config_GetUserDir( VLC_CONFIG_DIR );
+ if (psz_dir == NULL)
+ return NULL;
if( asprintf( &psz_file, "%s" DIR_SEP CONFIG_FILE, psz_dir ) == -1 )
psz_file = NULL;
=====================================
src/preparser/art.c
=====================================
@@ -61,6 +61,9 @@ static char* ArtCacheGetDirPath( const char *psz_arturl, const char *psz_artist,
char *psz_dir;
char *psz_cachedir = config_GetUserDir(VLC_CACHE_DIR);
+ if (unlikely(psz_cachedir == NULL))
+ return NULL;
+
if( !EMPTY_STR(psz_artist) && !EMPTY_STR(psz_album) )
{
char *psz_album_sanitized = strdup( psz_album );
@@ -225,6 +228,8 @@ static char * GetDirByItemUIDs( char *psz_uid )
{
char *psz_cachedir = config_GetUserDir(VLC_CACHE_DIR);
char *psz_dir;
+ if (unlikely(psz_cachedir == NULL))
+ return NULL;
if( asprintf( &psz_dir, "%s" DIR_SEP
"by-iiuid" DIR_SEP
"%s",
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/37496d31d6f0b9343550eead83990e45c556dda9...250e0193b679611f6c8736082b851f156fd77874
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/37496d31d6f0b9343550eead83990e45c556dda9...250e0193b679611f6c8736082b851f156fd77874
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