Ticket #5141: libs_libmythtv_osdimagecache.cpp-check-QFile-open.patch

File libs_libmythtv_osdimagecache.cpp-check-QFile-open.patch, 914 bytes (added by Erik Hovland <erik@…>, 12 years ago)

check QFile::open()

  • libs/libmythtv/osdimagecache.cpp

    A call to QFile::open() is not checked. It can return false if things don't work out.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythtv/osdimagecache.cpp |    8 +++++++-
     1 files changed, 7 insertions(+), 1 deletions(-)
    
    diff --git a/libs/libmythtv/osdimagecache.cpp b/libs/libmythtv/osdimagecache.cpp
    index a3f986a..d5be817 100644
    a b OSDImageCacheValue *OSDImageCache::Get(const QString &key, bool useFile) 
    172172
    173173    QDir dir(MythContext::GetConfDir() + "/osdcache/");
    174174    QFile cacheFile(dir.path() + "/" + key);
    175     cacheFile.open(QIODevice::ReadOnly);
     175    if (!cacheFile.open(QIODevice::IO_ReadOnly))
     176    {
     177        VERBOSE(VB_IMPORTANT,
     178                LOC_ERR + key + " Failed opening read-only cache file");
     179        return NULL;
     180    }
     181
    176182    uint32_t imwidth  = 0;
    177183    uint32_t imheight = 0;
    178184