Linux: Fix heap-buffer-overflow when passing command-line arguments to cef_unittests (issue #1458).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2037 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2015-03-02 17:26:11 +00:00
parent bfac5a1c46
commit 031f192e5a
1 changed files with 3 additions and 1 deletions

View File

@ -97,11 +97,13 @@ struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> { };
class CefScopedArgArray {
public:
CefScopedArgArray(int argc, char* argv[]) {
array_ = new char*[argc];
// argv should have (argc + 1) elements, the last one always being NULL.
array_ = new char*[argc + 1];
for (int i = 0; i < argc; ++i) {
values_.push_back(argv[i]);
array_[i] = const_cast<char*>(values_[i].c_str());
}
array_[argc] = NULL;
}
~CefScopedArgArray() {
delete [] array_;