From 88798cff29934b58e0a8d81e94005472d612b964 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 14 Aug 2018 18:26:36 +0000 Subject: Remove CFX_BufferSeekableReadStream. Replace it with CFX_ReadOnlyMemoryStream, which does the same thing. Take some checks from CFX_BufferSeekableReadStream and add them CFX_ReadOnlyMemoryStream. Change-Id: I25554c3aec3ec96967f8df16ca68a64dba121b6f Reviewed-on: https://pdfium-review.googlesource.com/40070 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- core/fxcrt/cfx_readonlymemorystream.cpp | 2 +- core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp | 6 +++--- core/fxcrt/xml/cfx_xmlparser_unittest.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/cfx_readonlymemorystream.cpp b/core/fxcrt/cfx_readonlymemorystream.cpp index a01ed2e474..0a1a53a456 100644 --- a/core/fxcrt/cfx_readonlymemorystream.cpp +++ b/core/fxcrt/cfx_readonlymemorystream.cpp @@ -21,7 +21,7 @@ FX_FILESIZE CFX_ReadOnlyMemoryStream::GetSize() { bool CFX_ReadOnlyMemoryStream::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { - if (offset < 0) + if (!buffer || offset < 0 || size == 0) return false; FX_SAFE_SIZE_T pos = size; diff --git a/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp b/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp index 0109ab2985..c1fbad5f0f 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp +++ b/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp @@ -4,10 +4,10 @@ #include "core/fxcrt/xml/cfx_xmlinstruction.h" +#include "core/fxcrt/cfx_readonlymemorystream.h" #include "core/fxcrt/xml/cfx_xmldocument.h" #include "core/fxcrt/xml/cfx_xmlelement.h" #include "core/fxcrt/xml/cfx_xmlparser.h" -#include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/string_write_stream.h" #include "testing/test_support.h" @@ -86,7 +86,7 @@ TEST(CFX_XMLInstructionTest, ParseAndReSave) { "\n" ""; - auto in_stream = pdfium::MakeRetain( + auto in_stream = pdfium::MakeRetain( pdfium::as_bytes(pdfium::make_span(input))); CFX_XMLParser parser(in_stream); @@ -119,7 +119,7 @@ TEST(CFX_XMLInstructionTest, ParseAndReSaveInnerInstruction) { "\n" ""; - auto in_stream = pdfium::MakeRetain( + auto in_stream = pdfium::MakeRetain( pdfium::as_bytes(pdfium::make_span(input))); CFX_XMLParser parser(in_stream); diff --git a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp index c1236ce182..86d340ea83 100644 --- a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp +++ b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp @@ -6,11 +6,11 @@ #include +#include "core/fxcrt/cfx_readonlymemorystream.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/xml/cfx_xmldocument.h" #include "core/fxcrt/xml/cfx_xmlelement.h" #include "core/fxcrt/xml/cfx_xmlinstruction.h" -#include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" #include "third_party/base/ptr_util.h" @@ -18,8 +18,8 @@ class CFX_XMLParserTest : public testing::Test { public: std::unique_ptr Parse(pdfium::span input) { - CFX_XMLParser parser(pdfium::MakeRetain( - pdfium::as_bytes(input))); + CFX_XMLParser parser( + pdfium::MakeRetain(pdfium::as_bytes(input))); return parser.Parse(); } }; -- cgit v1.2.3