Skip to content

Commit

Permalink
Fix potential null pointer dereferences in videodlg.cpp.
Browse files Browse the repository at this point in the history
The compiler seems to believe that the m_d->m_videoList can be changed
inside of some of these functions.  Adding additional checks on the
validity of this pointer eliminates changes of dereferencing the
(possibly null) data pointer.

Unsure why putting the results of getListCache() into a temporary
variable eliminates the compiler warning about a null dereference,
unless somehow that forces the compiler to prune paths and prune out
the path that includes the nullptr.
  • Loading branch information
linuxdude42 committed Jan 2, 2025
1 parent 9569fb2 commit f81d273
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions mythtv/programs/mythfrontend/videodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,10 +1390,12 @@ void VideoDialog::fetchVideos()
}
else
{
m_d->m_videoList->refreshList(m_d->m_isFileBrowser,
if (m_d->m_videoList)
m_d->m_videoList->refreshList(m_d->m_isFileBrowser,
m_d->m_parentalLevel.GetLevel(),
m_d->m_isFlatList, m_d->m_groupType);
m_d->m_rootNode = m_d->m_videoList->GetTreeRoot();
if(m_d->m_videoList)
m_d->m_rootNode = m_d->m_videoList->GetTreeRoot();
}

m_d->m_treeLoaded = true;
Expand Down Expand Up @@ -3089,7 +3091,10 @@ void VideoDialog::playVideo()
{
VideoMetadata *metadata = GetMetadata(GetItemCurrent());
if (metadata)
PlayVideo(metadata->GetFilename(), m_d->m_videoList->getListCache());
{
auto cache = m_d->m_videoList->getListCache();
PlayVideo(metadata->GetFilename(), cache);
}
}

/** \fn VideoDialog::playVideoAlt()
Expand All @@ -3100,8 +3105,10 @@ void VideoDialog::playVideoAlt()
{
VideoMetadata *metadata = GetMetadata(GetItemCurrent());
if (metadata)
PlayVideo(metadata->GetFilename(),
m_d->m_videoList->getListCache(), true);
{
auto cache = m_d->m_videoList->getListCache();
PlayVideo(metadata->GetFilename(), cache, true);
}
}

/** \fn VideoDialog::playFolder()
Expand Down Expand Up @@ -3139,8 +3146,8 @@ void VideoDialog::playFolder()
{
playing_time.start();
video_started = true;
PlayVideo(metadata->GetFilename(),
m_d->m_videoList->getListCache());
auto cache = m_d->m_videoList->getListCache();
PlayVideo(metadata->GetFilename(), cache);
}
}
i++;
Expand Down Expand Up @@ -3610,7 +3617,7 @@ void VideoDialog::OnRemoveVideo(bool dodelete)
if (!metadata)
return;

if (m_d->m_videoList->Delete(metadata->GetID()))
if (m_d->m_videoList && m_d->m_videoList->Delete(metadata->GetID()))
{
if (m_videoButtonTree)
m_videoButtonTree->RemoveItem(item, false); // FIXME Segfault when true
Expand Down

0 comments on commit f81d273

Please sign in to comment.