From 05daf76e95e1478571c50b95c09f72c1138531d0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 2 Mar 2015 17:27:18 +0000 Subject: [PATCH] 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 --- include/wrapper/cef_helpers.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/wrapper/cef_helpers.h b/include/wrapper/cef_helpers.h index 642313969..639cde8cb 100644 --- a/include/wrapper/cef_helpers.h +++ b/include/wrapper/cef_helpers.h @@ -97,11 +97,13 @@ struct CefDeleteOnRendererThread : public CefDeleteOnThread { }; 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(values_[i].c_str()); } + array_[argc] = NULL; } ~CefScopedArgArray() { delete [] array_;