From aadf2cd19c4f77fba821f8a2c7bf9a34dc07b8c0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 11 Dec 2013 17:56:28 -0800 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/subsurfacewebservices.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'qt-ui') 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++) { -- cgit v1.2.3-70-g09d2