Fix dangling pointers in CefScopedArgArray (fixes issue #2704).

This commit is contained in:
Alexander Guettler 2019-07-16 21:42:20 +00:00 committed by Marshall Greenblatt
parent 3f1ebebde5
commit 17ec55a3b3
1 changed files with 2 additions and 1 deletions

View File

@ -97,8 +97,9 @@ class CefScopedArgArray {
CefScopedArgArray(int argc, char* argv[]) { CefScopedArgArray(int argc, char* argv[]) {
// argv should have (argc + 1) elements, the last one always being NULL. // argv should have (argc + 1) elements, the last one always being NULL.
array_ = new char*[argc + 1]; array_ = new char*[argc + 1];
values_.resize(argc);
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
values_.push_back(argv[i]); values_[i] = argv[i];
array_[i] = const_cast<char*>(values_[i].c_str()); array_[i] = const_cast<char*>(values_[i].c_str());
} }
array_[argc] = NULL; array_[argc] = NULL;