[PATCH 2/9] Don't leak the zip structure if no dives are selected
Thiago Macieira
thiago at macieira.org
Wed Dec 11 17:56:28 UTC 2013
Just move the check above the zip_open call.
Signed-off-by: Thiago Macieira <thiago at macieira.org>
---
qt-ui/subsurfacewebservices.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index c0091fc..619714d 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++) {
--
1.7.11.7
More information about the subsurface
mailing list