diff options
author | Manoj Gupta <manojgupta@google.com> | 2018-02-02 15:57:16 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-03 04:44:09 -0800 |
commit | 6d2c71e261e331def8d41caea5a254f6312ece76 (patch) | |
tree | 491bf636dff535f7e6ca425f305f9e7848d0c2b7 /test_http_server.cc | |
parent | f94b643ff1bb0f07204ec9f15289b55ac5fedacd (diff) |
update_engine: Fix a stack use after scope issue.
GetCStr() returns the contents to a local string returned by Get().
The string is destroyed after the call to GetCStr() so the pointer
passed to atoi() is not valid.
Change Get() to return a reference instead so that it will stay valid
for lifetime of atoi().
BUG=chromium:808686
TEST=No more asan complains.
Change-Id: Icc62064f4f3382a29ccbd36ca90f9952cf149364
Reviewed-on: https://chromium-review.googlesource.com/899512
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Diffstat (limited to 'test_http_server.cc')
-rw-r--r-- | test_http_server.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test_http_server.cc b/test_http_server.cc index 2955e79f..39a12ed5 100644 --- a/test_http_server.cc +++ b/test_http_server.cc @@ -494,7 +494,7 @@ class UrlTerms { CHECK_EQ(terms.size(), num_terms); } - inline string Get(const off_t index) const { + inline const string& Get(const off_t index) const { return terms[index]; } inline const char *GetCStr(const off_t index) const { |