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

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/2272@2038 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2015-03-02 17:27:18 +00:00
parent f51610dd36
commit 05daf76e95

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_;