mirror of
https://pdfium.googlesource.com/pdfium
synced 2026-08-02 20:37:52 +08:00
Bug: pdfium:2127 Change-Id: I6958fd117a550a8c46a43265ee46370bd1615f38 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/116851 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Thomas Sepez <tsepez@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
27 lines
768 B
C++
27 lines
768 B
C++
// 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 <string.h>
|
|
|
|
#include "core/fxcrt/check_op.h"
|
|
#include "core/fxcrt/numerics/checked_math.h"
|
|
|
|
TestLoader::TestLoader(pdfium::span<const uint8_t> span) : m_Span(span) {}
|
|
|
|
// static
|
|
int TestLoader::GetBlock(void* param,
|
|
unsigned long pos,
|
|
unsigned char* pBuf,
|
|
unsigned long size) {
|
|
TestLoader* pLoader = static_cast<TestLoader*>(param);
|
|
pdfium::CheckedNumeric<size_t> end = pos;
|
|
end += size;
|
|
CHECK_LE(end.ValueOrDie(), pLoader->m_Span.size());
|
|
|
|
memcpy(pBuf, &pLoader->m_Span[pos], size);
|
|
return 1;
|
|
}
|