wrappers: Take the argv null terminator into account when checking for overflows
When adding the terminator without incrementing arg and checking for overflows with "arg > max_arg", we need to allocate space for one extra element for the implicit terminator.
This commit is contained in:
1 parent
013dfc08e4
commit
66055dfe63
2 files changed
+2
-2
No files matched your search
@@ -272,7 +272,7 @@ int _tmain(int argc, TCHAR* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int max_arg = argc + 20;
|
int max_arg = argc + 20;
|
||||||
const TCHAR **exec_argv = malloc(max_arg * sizeof(*exec_argv));
|
const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
|
||||||
int arg = 0;
|
int arg = 0;
|
||||||
if (getenv("CCACHE"))
|
if (getenv("CCACHE"))
|
||||||
exec_argv[arg++] = _T("ccache");
|
exec_argv[arg++] = _T("ccache");
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ int _tmain(int argc, TCHAR* argv[]) {
|
|||||||
|
|
||||||
|
|
||||||
int max_arg = 2 * argc + 20;
|
int max_arg = 2 * argc + 20;
|
||||||
const TCHAR **exec_argv = malloc(max_arg * sizeof(*exec_argv));
|
const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
|
||||||
int arg = 0;
|
int arg = 0;
|
||||||
|
|
||||||
if (!_tcscmp(input_format, _T("rc"))) {
|
if (!_tcscmp(input_format, _T("rc"))) {
|
||||||
|
|||||||
Reference in new issue
Block a user