diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-06-22 06:46:01 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-22 10:57:56 -0700 |
commit | 90f20f4c7686cf10890f5b7ccb95e4dc8c8a2054 (patch) | |
tree | 92af4717638b70e9f3dcb5f8c09bccbbdd963a0e /qt-ui | |
parent | 64c7202e2d265a98130a91bade73f14cf22541e5 (diff) | |
download | subsurface-90f20f4c7686cf10890f5b7ccb95e4dc8c8a2054.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
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 |