Ticket #4742: check-dyncast-in-mythmainwindow.patch

File check-dyncast-in-mythmainwindow.patch, 957 bytes (added by Erik Hovland <erik@…>, 12 years ago)

Checks dyncast for null in mythui

  • libs/libmythui/mythmainwindow.cpp

    Unfortunately dynamic_cast can fail. When it does, it returns a null
    
    From: Erik Hovland <erik@hovland.org>
    
    pointer. So any pointer gotten from a dynamic_cast should be checked.
    In mythmainwindow, the eventFilter member function does a
    dynamic_cast of the event into a key event.
    
    This patch makes sure we don't dereference that key event pointer if the
    dynamic_cast didn't work.
    ---
    
     libs/libmythui/mythmainwindow.cpp |    2 ++
     1 files changed, 2 insertions(+), 0 deletions(-)
    
    diff --git a/libs/libmythui/mythmainwindow.cpp b/libs/libmythui/mythmainwindow.cpp
    index 8504cd5..a2b6942 100644
    a b bool MythMainWindow::eventFilter(QObject *, QEvent *e) 
    11711171        case QEvent::KeyPress:
    11721172        {
    11731173            QKeyEvent *ke = dynamic_cast<QKeyEvent*>(e);
     1174            if (!ke)
     1175                return false;
    11741176
    11751177            if (currentWidget())
    11761178            {