Skip to content

Commit

Permalink
[DanglingPointer] Removed dangling pointer saved_files_service_unitte…
Browse files Browse the repository at this point in the history
…st.cc

Fixed Dangling pointer by assigning null value to |extension_| before replacing with a new reference owned by the extension system

Bug: 1291138
Change-Id: I2eb696de70161119c365932799d7a97c0bb805df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4930425
Reviewed-by: Trent Apted <tapted@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209953}
  • Loading branch information
neehit authored and Chromium LUCI CQ committed Oct 16, 2023
1 parent 8371b51 commit ab7ce77
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/saved_files_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SavedFilesServiceUnitTest : public testing::Test {
}

extensions::TestExtensionEnvironment env_;
raw_ptr<const extensions::Extension, DanglingUntriaged> extension_;
raw_ptr<const extensions::Extension> extension_;
raw_ptr<SavedFilesService> service_;
base::FilePath path_;
};
Expand Down Expand Up @@ -152,6 +152,7 @@ TEST_F(SavedFilesServiceUnitTest, NoRetainEntriesPermissionTest) {
static const char kManifest[] =
"{\"app\": {\"background\": {\"scripts\": [\"background.js\"]}},"
"\"permissions\": [\"fileSystem\"]}";
extension_ = nullptr;
extension_ = env_.MakeExtension(base::test::ParseJsonDict(kManifest));
service_->RegisterFileEntry(extension_->id(), GenerateId(1), path_, true);
TRACE_CALL(CheckEntrySequenceNumber(1, 0));
Expand Down

0 comments on commit ab7ce77

Please sign in to comment.