1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Windows: check for malloc failures and report error in such cases.

This commit is contained in:
Mounir IDRASSI
2016-09-26 13:09:48 +02:00
parent b65eabe23d
commit 3c09765208

View File

@@ -519,6 +519,11 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
LoadKeyList (hwndDlg, param->FirstKeyFile);
kf = (KeyFile *) malloc (sizeof (KeyFile));
if (!kf)
{
Warning ("ERR_MEM_ALLOC", hwndDlg);
break;
}
}
} while (SelectMultipleFilesNext (kf->FileName, sizeof(kf->FileName)));
@@ -528,6 +533,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
}
if (kf)
free (kf);
}
return 1;
@@ -536,7 +542,8 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDC_ADD_KEYFILE_PATH)
{
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName))
{
param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
@@ -546,6 +553,11 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
{
free (kf);
}
}
else
{
Warning ("ERR_MEM_ALLOC", hwndDlg);
}
return 1;
}
@@ -716,12 +728,18 @@ BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *par
{
param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
kf = (KeyFile *) malloc (sizeof (KeyFile));
if (!kf)
{
Warning ("ERR_MEM_ALLOC", hwndDlg);
break;
}
} while (SelectMultipleFilesNext (kf->FileName, sizeof(kf->FileName)));
param->EnableKeyFiles = TRUE;
status = TRUE;
}
if (kf)
free (kf);
}
}
@@ -743,6 +761,10 @@ BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *par
free (kf);
}
}
else
{
Warning ("ERR_MEM_ALLOC", hwndDlg);
}
}
break;
@@ -762,6 +784,11 @@ BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *par
param->EnableKeyFiles = TRUE;
status = TRUE;
}
else
{
Warning ("ERR_MEM_ALLOC", hwndDlg);
break;
}
}
}
}