VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-07-09 05:35:56 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 23:20:43 +0100
commit899a22b840316d54a9563726e78f7a201a6702ef (patch)
tree9a3fe9f081b3b9554c29bc6b3cd6f3ae50def710
parent5281e2d3b9adea8dff1730d78fe94af85582aea8 (diff)
downloadVeraCrypt-899a22b840316d54a9563726e78f7a201a6702ef.tar.gz
VeraCrypt-899a22b840316d54a9563726e78f7a201a6702ef.zip
Static Code Analysis : fix various memory leaks.
-rw-r--r--src/Common/Cmdline.c2
-rw-r--r--src/Common/Dlgcode.c4
-rw-r--r--src/Format/Tcformat.c9
-rw-r--r--src/Mount/Mount.c5
4 files changed, 16 insertions, 4 deletions
diff --git a/src/Common/Cmdline.c b/src/Common/Cmdline.c
index cf3903d6..35507c2b 100644
--- a/src/Common/Cmdline.c
+++ b/src/Common/Cmdline.c
@@ -55,6 +55,8 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
}
SetWindowText (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), (char*) tmp);
+
+ TCfree(tmp);
return 1;
}
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index f645fdec..084e93d5 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -6743,7 +6743,11 @@ __int64 FindStringInFile (const char *filePath, const char* str, int strLen)
|| buffer == NULL
|| strLen > bufSize
|| strLen < 1)
+ {
+ if (buffer)
+ free (buffer);
return -1;
+ }
src = CreateFile (filePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 5d830d0d..18dd23ce 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -7771,7 +7771,7 @@ ovf_end:
void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
- char **lpszCommandLineArgs; /* Array of command line arguments */
+ char **lpszCommandLineArgs = NULL; /* Array of command line arguments */
int nNoCommandLineArgs; /* The number of arguments in the array */
if (_stricmp (lpszCommandLine, "-Embedding") == 0)
@@ -8012,6 +8012,9 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
free (lpszCommandLineArgs[nNoCommandLineArgs]);
}
+
+ if (lpszCommandLineArgs)
+ free (lpszCommandLineArgs);
}
@@ -8277,7 +8280,7 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int
if (lpOutBuffer == NULL)
{
MessageBoxW (hwndDlg, GetString ("ERR_MEM_ALLOC"), lpszTitle, ICON_HAND);
- goto vcmf_error;
+ goto vcm_error;
}
lpInBuffer.StartingLcn.QuadPart = 0;
@@ -8328,7 +8331,7 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int
vcm_error:
CloseHandle (hDevice);
- free(lpOutBuffer);
+ if (lpOutBuffer) free(lpOutBuffer);
vcmf_error:
return -1;
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index eee282a8..3cf9b9a7 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -6566,7 +6566,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
- char **lpszCommandLineArgs; /* Array of command line arguments */
+ char **lpszCommandLineArgs = NULL; /* Array of command line arguments */
int nNoCommandLineArgs; /* The number of arguments in the array */
char tmpPath[MAX_PATH * 2];
@@ -6842,6 +6842,9 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
free (lpszCommandLineArgs[nNoCommandLineArgs]);
}
+
+ if (lpszCommandLineArgs)
+ free (lpszCommandLineArgs);
}