Ticket #4829: libs_libmyth_util.cpp-check-stat.patch

File libs_libmyth_util.cpp-check-stat.patch, 787 bytes (added by Erik Hovland <erik@…>, 18 years ago)

checks stat for errors

  • libs/libmyth/util.cpp

    Check stat for a proper return value. If it failes return zero length for
    
    From: Erik Hovland <erik@hovland.org>
    
    file to check.
    ---
    
     libs/libmyth/util.cpp |    4 +++-
     1 files changed, 3 insertions(+), 1 deletions(-)
    
    diff --git a/libs/libmyth/util.cpp b/libs/libmyth/util.cpp
    index 97c289a..13396d5 100644
    a b unsigned long long myth_get_approximate_large_file_size(const QString &fname)  
    946946    return status.st_size;
    947947#else
    948948    struct stat status;
    949     stat(filename.local8Bit(), &status);
     949    if (stat(filename.local8Bit(), &status) == -1)
     950        return 0;
     951
    950952    // Using off_t requires a lot of 32/64 bit checking.
    951953    // So just get the size in blocks.
    952954    unsigned long long bsize = status.st_blksize;