Skip to content

Commit

Permalink
tidy: Fix a couple of nullptr dereferences.
Browse files Browse the repository at this point in the history
The clang-tidy "non null parameter" checker pointed out a couple of
places where null pointers were passed to functions that then
dereference them.  Fix these by adding tests for nullptr within the
function.

https://clang.llvm.org/extra/clang-tidy/checks/clang-analyzer-core.NonNullParamChecker.html
  • Loading branch information
linuxdude42 committed Dec 3, 2019
1 parent 4b82e6b commit ab315e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions mythplugins/mythweather/mythweather/weatherSource.cpp
Expand Up @@ -316,9 +316,11 @@ ScriptInfo *WeatherSource::ProbeScript(const QFileInfo &fi)
return new ScriptInfo(info);
}

/*
/**
* Watch out, we store the parameter as a member variable, don't go deleting it,
* that wouldn't be good.
*
* \param info is a required variable.
*/
WeatherSource::WeatherSource(ScriptInfo *info)
: m_ready(info != nullptr),
Expand All @@ -330,9 +332,11 @@ WeatherSource::WeatherSource(ScriptInfo *info)
if (!dir.exists("MythWeather"))
dir.mkdir("MythWeather");
dir.cd("MythWeather");
if (!dir.exists(info->name))
dir.mkdir(info->name);
dir.cd(info->name);
if (info != nullptr) {
if (!dir.exists(info->name))
dir.mkdir(info->name);
dir.cd(info->name);
}
m_dir = dir.absolutePath();

connect( m_updateTimer, SIGNAL(timeout()), this, SLOT(updateTimeout()));
Expand Down
6 changes: 4 additions & 2 deletions mythtv/libs/libmythtv/recorders/NuppelVideoRecorder.cpp
Expand Up @@ -1556,7 +1556,8 @@ void NuppelVideoRecorder::DoV4L2(void)

if (!m_request_pause)
{
if (m_v4l2_pixelformat == V4L2_PIX_FMT_YUYV)
if ((m_v4l2_pixelformat == V4L2_PIX_FMT_YUYV) &&
(output_buffer != nullptr))
{
AVFrame img_in;
av_image_fill_arrays(img_in.data, img_in.linesize,
Expand All @@ -1566,7 +1567,8 @@ void NuppelVideoRecorder::DoV4L2(void)
0, m_height, img_out.data, img_out.linesize);
BufferIt(output_buffer, m_video_buffer_size);
}
else if (m_v4l2_pixelformat == V4L2_PIX_FMT_UYVY)
else if ((m_v4l2_pixelformat == V4L2_PIX_FMT_UYVY) &&
(output_buffer != nullptr))
{
AVFrame img_in;
av_image_fill_arrays(img_in.data, img_in.linesize,
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythfrontend/progdetails.cpp
Expand Up @@ -827,7 +827,7 @@ void ProgDetails::loadPage(void)
}
else if (m_progInfo.GetRecordingRuleID())
{
recordingProfile = record->m_recProfile;
recordingProfile = record ? record->m_recProfile : tr("Unknown");
}
addItem(tr("Recording Host"), recordingHost, ProgInfoList::kLevel2);
addItem(tr("Recording Input"), recordingInput, ProgInfoList::kLevel2);
Expand Down

0 comments on commit ab315e5

Please sign in to comment.