Commit d5067663 authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Fix regressions in Mac ASAN build due to 150054

Switched to returning std::string instead of base::StringPiece in GetScaleFactorsAsString() as base::StringPiece does not take ownership of data passed to it in the constructor.

TBR=sky

Review URL: https://chromiumcodereview.appspot.com/10854003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150058 0039d316-1c4b-4281-b951-d872f2087c98
parent 3736bfda
......@@ -203,15 +203,15 @@ bool InputScalesValid(const char* input,
}
// Returns |scale_factors| as a string to be written to disk.
base::StringPiece GetScaleFactorsAsString(
std::string GetScaleFactorsAsString(
const std::vector<ui::ScaleFactor>& scale_factors) {
size_t scales_size = scale_factors.size() + 1;
float* scales = new float[scales_size];
for (size_t i = 0; i < scale_factors.size(); ++i)
scales[i] = ui::GetScaleFactorScale(scale_factors[i]);
scales[scales_size - 1] = -1.0f;
base::StringPiece out_string = base::StringPiece(
reinterpret_cast<const char*>(&scales),
std::string out_string = std::string(
reinterpret_cast<const char*>(scales),
scales_size * sizeof(float));
delete[] scales;
return out_string;
......@@ -540,7 +540,10 @@ bool BrowserThemePack::WriteToDisk(const FilePath& path) const {
reinterpret_cast<const char*>(source_images_),
source_count * sizeof(*source_images_));
resources[kScaleFactorsID] = GetScaleFactorsAsString(scale_factors_);
// Store results of GetScaleFactorsAsString() in std::string as
// base::StringPiece does not copy data in constructor.
std::string scale_factors_string = GetScaleFactorsAsString(scale_factors_);
resources[kScaleFactorsID] = scale_factors_string;
AddRawImagesTo(image_memory_, &resources);
......
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