Commit 87318c85 authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

[AW] Use ScopedFD when reading finch seeds in WebView

This CL fixes a missing close() call in VariationsSeedLoader by using
ScopedFD instead of a raw int when opening the seed file.

Bug: 1138713
Change-Id: I547769c6385507cbe8fc876eb233dd0eacdb2d6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519741Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826530}
parent 995628f8
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/scoped_file.h"
using base::android::ConvertJavaStringToUTF8; using base::android::ConvertJavaStringToUTF8;
using base::android::ConvertUTF8ToJavaString; using base::android::ConvertUTF8ToJavaString;
...@@ -29,8 +30,8 @@ static jboolean JNI_VariationsSeedLoader_ParseAndSaveSeedProto( ...@@ -29,8 +30,8 @@ static jboolean JNI_VariationsSeedLoader_ParseAndSaveSeedProto(
std::unique_ptr<AwVariationsSeed> seed = std::unique_ptr<AwVariationsSeed> seed =
std::make_unique<AwVariationsSeed>(AwVariationsSeed::default_instance()); std::make_unique<AwVariationsSeed>(AwVariationsSeed::default_instance());
std::string native_seed_path = ConvertJavaStringToUTF8(seed_path); std::string native_seed_path = ConvertJavaStringToUTF8(seed_path);
int seed_fd = open(native_seed_path.c_str(), O_RDONLY); base::ScopedFD seed_fd(open(native_seed_path.c_str(), O_RDONLY));
if (!seed->ParseFromFileDescriptor(seed_fd)) { if (!seed->ParseFromFileDescriptor(seed_fd.get())) {
return false; return false;
} }
......
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