summaryrefslogtreecommitdiffstats
path: root/qt-ui/subsurfacewebservices.cpp
diff options
context:
space:
mode:
authorGravatar Thiago Macieira <thiago@macieira.org>2013-12-11 17:56:28 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-12 03:34:25 +0100
commitaadf2cd19c4f77fba821f8a2c7bf9a34dc07b8c0 (patch)
tree0f1aa77161d813401029173cad222bab089f759f /qt-ui/subsurfacewebservices.cpp
parent1b5b562da8eb328f5e7b9ad86796e526f88bba09 (diff)
downloadsubsurface-aadf2cd19c4f77fba821f8a2c7bf9a34dc07b8c0.tar.gz
Don't leak the zip structure if no dives are selected
Just move the check above the zip_open call. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/subsurfacewebservices.cpp')
-rw-r--r--qt-ui/subsurfacewebservices.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index c0091fc03..619714dee 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -100,6 +100,12 @@ static void clear_table(struct dive_table *table)
static char *prepare_dives_for_divelogs(const bool selected)
{
+ const QString errPrefix("divelog.de-upload:");
+ if (!amount_selected) {
+ qDebug() << errPrefix << "no dives selected";
+ return NULL;
+ }
+
int i;
struct dive *dive;
FILE *f;
@@ -111,7 +117,6 @@ static char *prepare_dives_for_divelogs(const bool selected)
xmlDoc *transformed;
struct zip_source *s[dive_table.nr];
struct zip *zip;
- const QString errPrefix("divelog.de-upload:");
/* generate a random filename and create/open that file with zip_open */
QString tempfileQ = QDir::tempPath() + "/import-" + QString::number(qrand() % 99999999) + ".dld";
@@ -123,11 +128,6 @@ static char *prepare_dives_for_divelogs(const bool selected)
free((void *)tempfile);
return NULL;
}
- if (!amount_selected) {
- qDebug() << errPrefix << "no dives selected";
- free((void *)tempfile);
- return NULL;
- }
/* walk the dive list in chronological order */
for (i = 0; i < dive_table.nr; i++) {