Commit 94b6e4e9 authored by Jian Li's avatar Jian Li Committed by Commit Bot

Check for empty MHTML archive resource

The passed SharedBuffer data may be null if the MHTML archive is
empty. Added a check for this.

Bug: 831443
Change-Id: Id675c801c7df94c9596d4a91a9ba5c7458f9936b
Reviewed-on: https://chromium-review.googlesource.com/1063033
Commit-Queue: Jian Li <jianli@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560741}
parent 30c13db2
......@@ -372,6 +372,15 @@ TEST_F(MHTMLArchiveTest, MHTMLDate) {
EXPECT_EQ(mhtml_date(), archive->Date());
}
TEST_F(MHTMLArchiveTest, EmptyArchive) {
char* buf = nullptr;
scoped_refptr<SharedBuffer> data =
SharedBuffer::Create(buf, static_cast<size_t>(0u));
KURL http_url = ToKURL("http://www.example.com");
MHTMLArchive* archive = MHTMLArchive::Create(http_url, data.get());
EXPECT_EQ(nullptr, archive);
}
} // namespace test
} // namespace blink
......@@ -149,6 +149,10 @@ MHTMLArchive::MHTMLArchive() = default;
MHTMLArchive* MHTMLArchive::Create(const KURL& url,
scoped_refptr<const SharedBuffer> data) {
// |data| may be null if archive file is empty.
if (!data)
return nullptr;
// MHTML pages can only be loaded from local URLs, http/https URLs, and
// content URLs(Android specific). The latter is now allowed due to full
// sandboxing enforcement on MHTML pages.
......
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