Skip to content

Commit

Permalink
Fix several possible null pointer dereferences in tv_play.cpp. Coveri…
Browse files Browse the repository at this point in the history
…ty defects 700398, 700399, 700400, 700401, 700402 & 700693
  • Loading branch information
stuartm committed May 30, 2012
1 parent 13209eb commit fb132ff
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions mythtv/libs/libmythtv/tv_play.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3450,7 +3450,7 @@ void TV::HandleSpeedChangeTimerEvent(void)
update_msg |= ctx->HandlePlayerSpeedChangeEOF() && (ctx == actx); update_msg |= ctx->HandlePlayerSpeedChangeEOF() && (ctx == actx);
} }


if (update_msg) if (actx && update_msg)
{ {
UpdateOSDSeekMessage(actx, actx->GetPlayMessage(), kOSDTimeout_Med); UpdateOSDSeekMessage(actx, actx->GetPlayMessage(), kOSDTimeout_Med);
} }
Expand Down Expand Up @@ -3693,7 +3693,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
handled |= GetMythMainWindow()->TranslateKeyPress( handled |= GetMythMainWindow()->TranslateKeyPress(
"TV Editing", e, actions); "TV Editing", e, actions);


if (!handled) if (!handled && actx->player)
{ {
if (has_action("MENU", actions)) if (has_action("MENU", actions))
{ {
Expand All @@ -3707,8 +3707,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
else else
{ {
actx->LockDeletePlayer(__FILE__, __LINE__); actx->LockDeletePlayer(__FILE__, __LINE__);
if (actx->player) actx->player->DisableEdit(0);
actx->player->DisableEdit(0);
actx->UnlockDeletePlayer(__FILE__, __LINE__); actx->UnlockDeletePlayer(__FILE__, __LINE__);
} }
handled = true; handled = true;
Expand All @@ -3731,7 +3730,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
} }
} }
if (handled) if (handled)
editmode = actx->player->GetEditMode(); editmode = (actx->player && actx->player->GetEditMode());
} }


if (handled) if (handled)
Expand Down Expand Up @@ -3802,7 +3801,7 @@ bool TV::ProcessKeypress(PlayerContext *actx, QKeyEvent *e)
handled = false; handled = false;


bool isDVD = actx->buffer && actx->buffer->IsDVD(); 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 || BrowseHandleAction(actx, actions);
handled = handled || ManualZoomHandleAction(actx, actions); handled = handled || ManualZoomHandleAction(actx, actions);
Expand Down Expand Up @@ -5234,10 +5233,11 @@ bool TV::PIPAddPlayer(PlayerContext *mctx, PlayerContext *pipctx)
return false; return false;


bool ok = false, addCondition = false; bool ok = false, addCondition = false;
bool is_using_null = false;
pipctx->LockDeletePlayer(__FILE__, __LINE__); pipctx->LockDeletePlayer(__FILE__, __LINE__);
if (pipctx->player) if (pipctx->player)
{ {
bool is_using_null = pipctx->player->UsingNullVideo(); is_using_null = pipctx->player->UsingNullVideo();
pipctx->UnlockDeletePlayer(__FILE__, __LINE__); pipctx->UnlockDeletePlayer(__FILE__, __LINE__);


if (is_using_null) if (is_using_null)
Expand All @@ -5263,7 +5263,7 @@ bool TV::PIPAddPlayer(PlayerContext *mctx, PlayerContext *pipctx)


LOG(VB_GENERAL, LOG_ERR, LOG(VB_GENERAL, LOG_ERR,
QString("AddPIPPlayer null: %1 IsPIP: %2 addCond: %3 ok: %4") 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)); .arg(pipctx->IsPIP()).arg(addCondition).arg(ok));


return ok; return ok;
Expand Down Expand Up @@ -5867,6 +5867,9 @@ void TV::DoTogglePause(PlayerContext *ctx, bool showOSD)


bool TV::DoPlayerSeek(PlayerContext *ctx, float time) bool TV::DoPlayerSeek(PlayerContext *ctx, float time)
{ {
if (!ctx || !ctx->buffer)
return false;

if (time > -0.001f && time < +0.001f) if (time > -0.001f && time < +0.001f)
return false; return false;


Expand Down Expand Up @@ -5975,10 +5978,13 @@ bool TV::SeekHandleAction(PlayerContext *actx, const QStringList &actions,
void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg, void TV::DoSeek(PlayerContext *ctx, float time, const QString &mesg,
bool timeIsOffset, bool honorCutlist) bool timeIsOffset, bool honorCutlist)
{ {
if (!ctx->player)
return;

bool limitkeys = false; bool limitkeys = false;


ctx->LockDeletePlayer(__FILE__, __LINE__); ctx->LockDeletePlayer(__FILE__, __LINE__);
if (ctx->player && ctx->player->GetLimitKeyRepeat()) if (ctx->player->GetLimitKeyRepeat())
limitkeys = true; limitkeys = true;
ctx->UnlockDeletePlayer(__FILE__, __LINE__); ctx->UnlockDeletePlayer(__FILE__, __LINE__);


Expand Down

0 comments on commit fb132ff

Please sign in to comment.