From bc1a5b1393b08be6871835a25cb23f6528965650 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 2 Dec 2022 09:50:44 -0800 Subject: [PATCH] Fix nullptr access when cow reader open fails Bug: 260805150 Test: th Change-Id: Id945cc4fa0fce141e3d52b8259241e22ba590ebd --- fs_mgr/libsnapshot/snapshot_writer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs_mgr/libsnapshot/snapshot_writer.cpp b/fs_mgr/libsnapshot/snapshot_writer.cpp index 6aad3d108..82a7fd7d6 100644 --- a/fs_mgr/libsnapshot/snapshot_writer.cpp +++ b/fs_mgr/libsnapshot/snapshot_writer.cpp @@ -93,6 +93,9 @@ bool CompressedSnapshotWriter::VerifyMergeOps() const noexcept { std::unique_ptr CompressedSnapshotWriter::OpenReader() { auto cow = OpenCowReader(); + if (cow == nullptr) { + return nullptr; + } auto reader = std::make_unique(); if (!reader->SetCow(std::move(cow))) {