Ticket #5524: programs_mythtranscode-null-return.patch

File programs_mythtranscode-null-return.patch, 1.3 KB (added by Erik Hovland <erik@…>, 11 years ago)

check return value of fopen before using

  • mythtv/programs/mythtranscode/main.cpp

    If a function can return a null pointer. That pointer
    
    From: Erik Hovland <erik@hovland.org>
    
    should be checked for validity.
    ---
    
     mythtv/programs/mythtranscode/main.cpp |   16 +++++++++++-----
     1 files changed, 11 insertions(+), 5 deletions(-)
    
    diff --git a/mythtv/programs/mythtranscode/main.cpp b/mythtv/programs/mythtranscode/main.cpp
    index 97a381e..0b9545b 100644
    a b void UpdatePositionMap(QMap <long long, long long> &posMap, QString mapfile, 
    683683    else if (!mapfile.isEmpty())
    684684    {
    685685        FILE *mapfh = fopen(mapfile, "w");
    686         QMap<long long, long long>::Iterator i;
    687         fprintf (mapfh, "Type: %d\n", MARK_GOP_BYFRAME);
    688         for (i = posMap.begin(); i != posMap.end(); ++i)
    689             fprintf(mapfh, "%lld %lld\n", i.key(), i.data());
    690         fclose(mapfh);
     686        if (mapfh)
     687        {
     688            QMap<long long, long long>::Iterator i;
     689            fprintf (mapfh, "Type: %d\n", MARK_GOP_BYFRAME);
     690            for (i = posMap.begin(); i != posMap.end(); ++i)
     691                fprintf(mapfh, "%lld %lld\n", i.key(), i.data());
     692            fclose(mapfh);
     693        }
     694        else
     695            VERBOSE(VB_GENERAL,
     696                    QString("Could not open map file %1").arg(mapfile));
    691697    }
    692698}
    693699