summaryrefslogtreecommitdiff
path: root/setup_native/source
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2015-12-13 09:27:00 +0100
committerJulien Nabet <serval2412@yahoo.fr>2015-12-13 10:20:14 +0000
commitd699266393d29227d249204faf5036fc0bd6d6ac (patch)
treed3677c4740669fbf79674dd92104fed7322b92e5 /setup_native/source
parentfd5708bfe8b034a825c0643ea9af73b2f976cd40 (diff)
cppcheck: fix memleak in win32/wintools/msidb/msidb.c
Change-Id: I60ce0dbb26a75b49a50a982214d7adfb7ab833a0 Reviewed-on: https://gerrit.libreoffice.org/20679 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'setup_native/source')
-rw-r--r--setup_native/source/win32/wintools/msidb/msidb.c76
1 files changed, 67 insertions, 9 deletions
diff --git a/setup_native/source/win32/wintools/msidb/msidb.c b/setup_native/source/win32/wintools/msidb/msidb.c
index b4242e1fb27a..733fe58b1205 100644
--- a/setup_native/source/win32/wintools/msidb/msidb.c
+++ b/setup_native/source/win32/wintools/msidb/msidb.c
@@ -119,24 +119,51 @@ static BOOL msidbExportStorage(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName)
sprintf(queryBuffer, "SELECT * FROM _Storages WHERE Name = '%s'", storageNameA);
r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle);
- if (r != ERROR_SUCCESS) return FALSE;
+ if (r != ERROR_SUCCESS)
+ {
+ free(storageNameA);
+ free(wdirA);
+ return FALSE;
+ }
MsiDatabaseOpenView(dbhandle, queryBuffer, &view);
MsiViewExecute(view, 0);
r = MsiViewFetch(view, &rec);
- if (r != ERROR_SUCCESS) return FALSE;
+ if (r != ERROR_SUCCESS)
+ {
+ free(storageNameA);
+ free(wdirA);
+ return FALSE;
+ }
if (MsiRecordReadStream(rec, 2, 0, &dataLen) != ERROR_SUCCESS)
{
+ free(storageNameA);
+ free(wdirA);
return FALSE;
}
- if ((dataBuffer = malloc(dataLen)) == NULL) return FALSE;
- if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS) return FALSE;
+ if ((dataBuffer = malloc(dataLen)) == NULL)
+ {
+ free(storageNameA);
+ free(wdirA);
+ return FALSE;
+ }
+ if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS)
+ {
+ free(storageNameA);
+ free(wdirA);
+ return FALSE;
+ }
len = strlen(wdirA) + strlen(storageNameA) + 2;
storagePath = malloc(len * sizeof(WCHAR));
- if (storagePath == NULL) return FALSE;
+ if (storagePath == NULL)
+ {
+ free(storageNameA);
+ free(wdirA);
+ return FALSE;
+ }
strcpy(storagePath, wdirA);
strcat(storagePath, "/");
@@ -232,24 +259,52 @@ static BOOL msidbExportStream(LPCWSTR dbfile, LPCWSTR wdir, LPCWSTR streamName)
DWORD dataLen = 0;
r = MsiOpenDatabaseW(dbfile, (LPCWSTR) MSIDBOPEN_READONLY, &dbhandle);
- if (r != ERROR_SUCCESS) return FALSE;
+ if (r != ERROR_SUCCESS)
+ {
+ free(wdirA);
+ free(streamNameA);
+ return FALSE;
+ }
sprintf(queryBuffer, "SELECT * FROM _Streams WHERE Name = '%s'", streamNameA);
MsiDatabaseOpenView(dbhandle, queryBuffer, &streamListView);
MsiViewExecute(streamListView, 0);
r = MsiViewFetch(streamListView, &rec);
- if (r != ERROR_SUCCESS) return FALSE;
+ if (r != ERROR_SUCCESS)
+ {
+ free(wdirA);
+ free(streamNameA);
+ return FALSE;
+ }
if (MsiRecordReadStream(rec, 2, 0, &dataLen) != ERROR_SUCCESS)
+ {
+ free(wdirA);
+ free(streamNameA);
return FALSE;
+ }
dataBuffer = malloc(dataLen);
- if (!dataBuffer) return FALSE;
+ if (!dataBuffer)
+ {
+ free(wdirA);
+ free(streamNameA);
+ return FALSE;
+ }
if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS)
+ {
+ free(wdirA);
+ free(streamNameA);
return FALSE;
+ }
len = strlen(streamNameA) + 5;
streamFileA = malloc(len);
- if (streamFileA == NULL) return FALSE;
+ if (streamFileA == NULL)
+ {
+ free(wdirA);
+ free(streamNameA);
+ return FALSE;
+ }
strcpy(streamFileA, streamNameA);
strcat(streamFileA, ext);
@@ -333,7 +388,10 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
}
}
else
+ {
+ free(dirNameA);
return FALSE;
+ }
closedir(dir);
free(dirNameA);
}