Commit bd593373 authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

[chromeos] Fix null-dereference in GetGeolocationFromResponse()

SimpleURLLoader does not return the response body by default for most
of error situations. The failing code was unconditionally
dereferencing the std::unique_ptr<std::string<>> holding the response
body and so, causing a crash.

Bots didn't complain when the CL landed because apparently log levels
greater than 0 are filtered out for unit tests (the line crashing was
a VLOG(1)). That's why an unit test is not provided.

Bug: 876627
Change-Id: Ibbc87955343fbab069cbc90b926593ffe6568ecd
Reviewed-on: https://chromium-review.googlesource.com/1196888Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Sergio Villar <svillar@igalia.com>
Cr-Commit-Position: refs/heads/master@{#587961}
parent 1b9fc29e
...@@ -494,9 +494,9 @@ void SimpleGeolocationRequest::OnSimpleURLLoaderComplete( ...@@ -494,9 +494,9 @@ void SimpleGeolocationRequest::OnSimpleURLLoaderComplete(
} }
RecordUmaResponseCode(response_code); RecordUmaResponseCode(response_code);
const bool parse_success = const bool parse_success = GetGeolocationFromResponse(
GetGeolocationFromResponse(is_success, response_code, *response_body, is_success, response_code, response_body ? *response_body : std::string(),
simple_url_loader_->GetFinalURL(), &position_); simple_url_loader_->GetFinalURL(), &position_);
// Note that SimpleURLLoader doesn't return a body for non-2xx // Note that SimpleURLLoader doesn't return a body for non-2xx
// responses by default. // responses by default.
const bool server_error = const bool server_error =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment