summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/subsurfacewebservices.cpp9
-rw-r--r--uemis-downloader.c12
2 files changed, 18 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
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 95cebe492..8b29eca3e 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -148,6 +148,8 @@ static long bytes_available(int file)
{
long result;
long now = lseek(file, 0, SEEK_CUR);
+ if (now == -1)
+ return 0;
result = lseek(file, 0, SEEK_END);
lseek(file, now, SEEK_SET);
if (now == -1 || result == -1)
@@ -516,6 +518,11 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
assembling_mbuf = false;
}
reqtxt_file = subsurface_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
+ if (reqtxt_file == -1) {
+ *error_text = "can't open req.txt";
+ fprintf(stderr, "open %s failed with errno %d\n", reqtxt_path, errno);
+ return false;
+ }
trigger_response(reqtxt_file, "n", filenr, file_length);
}
} else {
@@ -526,6 +533,11 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
searching = false;
}
reqtxt_file = subsurface_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
+ if (reqtxt_file == -1) {
+ *error_text = "can't open req.txt";
+ fprintf(stderr, "open %s failed with errno %d\n", reqtxt_path, errno);
+ return false;
+ }
trigger_response(reqtxt_file, "r", filenr, file_length);
uemis_increased_timeout(&timeout);
}