From b3d59cb89080d519f5629c224cf6359f80640e19 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 11 Dec 2013 17:56:31 -0800 Subject: Don't leak the buffer or temporary file used to save the dive Signed-off-by: Thiago Macieira Signed-off-by: Dirk Hohndel --- qt-ui/subsurfacewebservices.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 6be63fbad..2b51da8d6 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -155,6 +155,8 @@ static char *prepare_dives_for_divelogs(const bool selected) membuf = (char *)malloc(streamsize + 1); if (!membuf || !fread(membuf, streamsize, 1, f)) { qDebug() << errPrefix << "memory error"; + fclose(f); + free((void *)membuf); free((void *)tempfile); return NULL; } @@ -168,6 +170,7 @@ static char *prepare_dives_for_divelogs(const bool selected) doc = xmlReadMemory(membuf, strlen(membuf), "divelog", NULL, 0); if (!doc) { qDebug() << errPrefix << "xml error"; + free((void *)membuf); free((void *)tempfile); return NULL; } -- cgit v1.2.3-70-g09d2