// Copyright 2019 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "testing/test_loader.h" #include #include "third_party/base/check_op.h" #include "third_party/base/numerics/checked_math.h" TestLoader::TestLoader(pdfium::span span) : m_Span(span) {} // static int TestLoader::GetBlock(void* param, unsigned long pos, unsigned char* pBuf, unsigned long size) { TestLoader* pLoader = static_cast(param); pdfium::base::CheckedNumeric end = pos; end += size; CHECK_LE(end.ValueOrDie(), pLoader->m_Span.size()); memcpy(pBuf, &pLoader->m_Span[pos], size); return 1; }