[mythtv-commits] Ticket #13264: Crash (abort) in MythSocket::ResetReal

MythTV noreply at mythtv.org
Fri May 4 15:34:42 UTC 2018


#13264: Crash (abort) in MythSocket::ResetReal
------------------------------------+-------------------------
     Reporter:  Gary Buhrmaster     |      Owner:  (none)
         Type:  Bug Report - Crash  |     Status:  new
     Priority:  minor               |  Milestone:  unknown
    Component:  MythTV - General    |    Version:  Master Head
     Severity:  medium              |   Keywords:  gcc8
Ticket locked:  0                   |
------------------------------------+-------------------------
 In libmythbase mythsocket.cpp MythSocket::ResetReal there can be cases
 where there are no bytes to available to read, so the vector is never
 resized to greater than zero, which results in an abort when referencing
 the 1st (non-existant) element which is now checked by gcc8 (libstdc++).

 The abort was originally reported on the -users list when trying to
 playback video.

 There are a couple of approaches to avoid referencing a non-existant
 element.  My proposed patch just checks if there is going to be any bytes
 to read and skips any resizing and reading if not (skips some minor amount
 of work to do nothing anyway).


 If the proposed patch is accepted, the fix should likely be backported to
 any currently supported release.

 Proposed patch:

 {{{
 diff --git a/mythtv/libs/libmythbase/mythsocket.cpp
 b/mythtv/libs/libmythbase/mythsocket.cpp
 index 63f10b5331..bed0172cad 100644
 --- a/mythtv/libs/libmythbase/mythsocket.cpp
 +++ b/mythtv/libs/libmythbase/mythsocket.cpp
 @@ -1003,8 +1003,11 @@ void MythSocket::ResetReal(void)
      do
      {
          uint avail = m_tcpSocket->bytesAvailable();
 -        trash.resize(max((uint)trash.size(),avail));
 -        m_tcpSocket->read(&trash[0], avail);
 +        if (avail)
 +        {
 +            trash.resize(max((uint)trash.size(),avail));
 +            m_tcpSocket->read(&trash[0], avail);
 +        }

          LOG(VB_NETWORK, LOG_INFO, LOC + "Reset() " +
              QString("%1 bytes available").arg(avail));

 }}}

-- 
Ticket URL: <https://code.mythtv.org/trac/ticket/13264>
MythTV <http://www.mythtv.org>
MythTV Media Center


More information about the mythtv-commits mailing list