VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-09-26 13:09:48 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-10-17 18:40:17 +0200
commit3c09765208c82573155d1197386e593b93283896 (patch)
treec2aceaa70ac84353b84b9200226c4d89d58065c2 /src/Common
parentb65eabe23d5910a26d741439b1f5ea45ba4a0777 (diff)
downloadVeraCrypt-3c09765208c82573155d1197386e593b93283896.tar.gz
VeraCrypt-3c09765208c82573155d1197386e593b93283896.zip
Windows: check for malloc failures and report error in such cases.
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Keyfiles.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index 14d415f0..96e1cd7a 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -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,7 +533,8 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
}
- free (kf);
+ if (kf)
+ free (kf);
}
return 1;
}
@@ -536,16 +542,22 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDC_ADD_KEYFILE_PATH)
{
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
-
- if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName))
- {
- param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
- LoadKeyList (hwndDlg, param->FirstKeyFile);
- }
- else
- {
- free (kf);
- }
+ if (kf)
+ {
+ if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName))
+ {
+ param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
+ LoadKeyList (hwndDlg, param->FirstKeyFile);
+ }
+ else
+ {
+ free (kf);
+ }
+ }
+ else
+ {
+ Warning ("ERR_MEM_ALLOC", hwndDlg);
+ }
return 1;
}
@@ -716,13 +728,19 @@ 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;
}
- free (kf);
+ if (kf)
+ free (kf);
}
}
break;
@@ -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;
+ }
}
}
}