From 4f4fff3917d6352d3d40f20a1b6a9b4c3132e8e8 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 5 Mar 2014 18:30:52 -0800 Subject: Null terminate buffer at the correct spot fread tells us how many bytes it read. Signed-off-by: Dirk Hohndel --- qt-ui/subsurfacewebservices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 25aa56cb2..abf486035 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -159,7 +159,7 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile, rewind(f); membuf = (char *)malloc(streamsize + 1); - if (!membuf || !fread(membuf, streamsize, 1, f)) { + if (!membuf || (streamsize = fread(membuf, streamsize, 1, f)) == 0) { *errorMsg = tr("internal error: %1").arg(qt_error_string()); fclose(f); free((void *)membuf); -- cgit v1.2.3-70-g09d2