Permalink
Browse files

Fix several possible null pointer dereferences in tv_play.cpp. Coveri…

…ty defects 700398, 700399, 700400, 700401, 700402 & 700693
  • Loading branch information...
1 parent 13209eb commit fb132fff56755db8d7d536dc65f09b2dc1efcc5c @stuartm stuartm committed May 30, 2012
Showing with 15 additions and 9 deletions.
  1. +15 −9 mythtv/libs/libmythtv/tv_play.cpp
@@ -3450,7 +3450,7 @@ void TV::HandleSpeedChangeTimerEvent(void)
update_msg |= ctx->HandlePlayerSpeedChangeEOF() && (ctx == actx);
}
- if (update_msg)
+ if (actx && update_msg)
{
UpdateOSDSeekMessage(actx, actx->GetPlayMessage(), kOSDTimeout_Med);
}
@@ -3693,7 +3693,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
handled |= GetMythMainWindow()->TranslateKeyPress(
"TV Editing", e, actions);
- if (!handled)
+ if (!handled && actx->player)
{
if (has_action("MENU", actions))
{
@@ -3707,8 +3707,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
else
{
actx->LockDeletePlayer(__FILE__, __LINE__);
- if (actx->player)
- actx->player->DisableEdit(0);
+ actx->player->DisableEdit(0);
actx->UnlockDeletePlayer(__FILE__, __LINE__);
}
handled = true;
@@ -3731,7 +3730,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
}
}
if (handled)
- editmode = actx->player->GetEditMode();
+ editmode = (actx->player && actx->player->GetEditMode());
}
if (handled)
@@ -3802,7 +3801,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
handled = false;
bool isDVD = actx->buffer && actx->buffer->IsDVD();
- bool isMenuOrStill = actx->buffer->IsInDiscMenuOrStillFrame();
+ bool isMenuOrStill = actx->buffer && actx->buffer->IsInDiscMenuOrStillFrame();
handled = handled || BrowseHandleAction(actx, actions);
handled = handled || ManualZoomHandleAction(actx, actions);
@@ -5234,10 +5233,11 @@ bool TV::PIPAddPlayer(PlayerContext *mctx, PlayerContext *pipctx)
return false;
bool ok = false, addCondition = false;
+ bool is_using_null = false;
pipctx->LockDeletePlayer(__FILE__, __LINE__);
if (pipctx->player)
{
- bool is_using_null = pipctx->player->UsingNullVideo();
+ is_using_null = pipctx->player->UsingNullVideo();
pipctx->UnlockDeletePlayer(__FILE__, __LINE__);
if (is_using_null)
@@ -5263,7 +5263,7 @@ bool TV::PIPAddPlayer(PlayerContext *mctx, PlayerContext *pipctx)
LOG(VB_GENERAL, LOG_ERR,
QString("AddPIPPlayer null: %1 IsPIP: %2 addCond: %3 ok: %4")
- .arg(pipctx->player->UsingNullVideo())
+ .arg(is_using_null)
.arg(pipctx->IsPIP()).arg(addCondition).arg(ok));
return ok;
@@ -5867,6 +5867,9 @@ void TV::DoTogglePause(PlayerContext *ctx, bool showOSD)
bool TV::DoPlayerSeek(PlayerContext *ctx, float time)
{
+ if (!ctx || !ctx->buffer)
+ return false;
+
if (time > -0.001f && time < +0.001f)
return false;
@@ -5975,10 +5978,13 @@ bool TV::SeekHandleAction(PlayerContext *actx, const QStringList &actions,
void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg,
bool timeIsOffset, bool honorCutlist)
{
+ if (!ctx->player)
+ return;
+
bool limitkeys = false;
ctx->LockDeletePlayer(__FILE__, __LINE__);
- if (ctx->player && ctx->player->GetLimitKeyRepeat())
+ if (ctx->player->GetLimitKeyRepeat())
limitkeys = true;
ctx->UnlockDeletePlayer(__FILE__, __LINE__);

0 comments on commit fb132ff

Please sign in to comment.