From 90f20f4c7686cf10890f5b7ccb95e4dc8c8a2054 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 22 Jun 2015 06:46:01 -0700 Subject: Better error handling Most of these will likely have no big impact, but it's better not to just ignore them as they could lead to crashes. Uemis downloader: if lseek fails, return 0 Uemis downloader: consistently check for failure to open req.txt Zip file handling: dup could fail Signed-off-by: Dirk Hohndel --- qt-ui/subsurfacewebservices.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'qt-ui/subsurfacewebservices.cpp') diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index c7d8da0eb..6856654de 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -808,9 +808,12 @@ void DivelogsDeWebServices::downloadFinished() zipFile.seek(0); #if defined(Q_OS_UNIX) && defined(LIBZIP_VERSION_MAJOR) int duppedfd = dup(zipFile.handle()); - struct zip *zip = zip_fdopen(duppedfd, 0, &errorcode); - if (!zip) - ::close(duppedfd); + struct zip *zip = NULL; + if (duppedfd >= 0) { + zip = zip_fdopen(duppedfd, 0, &errorcode); + if (!zip) + ::close(duppedfd); + } #else struct zip *zip = zip_open(QFile::encodeName(zipFile.fileName()), 0, &errorcode); #endif -- cgit v1.2.3-70-g09d2