Conditionalize functions not needed under V8_ENABLE_SANDBOX
Change-Id: If7d7e858b530cd5c8ac7cdf4d0548e099303e3a1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/103217
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h
index 8157eb2..2ae5003 100644
--- a/core/fxcrt/fx_memory.h
+++ b/core/fxcrt/fx_memory.h
@@ -59,6 +59,7 @@
// FX_Free accepts memory from all of the above.
void FX_Free(void* ptr);
+#ifndef V8_ENABLE_SANDBOX
// V8 Array Buffer Partition Allocators.
// This never returns nullptr, and returns zeroed memory.
@@ -69,6 +70,7 @@
// FX_ArrayBufferFree accepts memory from both of the above.
void FX_ArrayBufferFree(void* data);
+#endif // V8_ENABLE_SANDBOX
namespace pdfium {
namespace internal {
diff --git a/core/fxcrt/fx_memory_pa.cpp b/core/fxcrt/fx_memory_pa.cpp
index e0d72d6..f68bc78 100644
--- a/core/fxcrt/fx_memory_pa.cpp
+++ b/core/fxcrt/fx_memory_pa.cpp
@@ -22,11 +22,13 @@
partition_alloc::PartitionOptions::UseConfigurablePool::kNo,
};
+#ifndef V8_ENABLE_SANDBOX
partition_alloc::PartitionAllocator& GetArrayBufferPartitionAllocator() {
static pdfium::base::NoDestructor<partition_alloc::PartitionAllocator>
s_array_buffer_allocator;
return *s_array_buffer_allocator;
}
+#endif // V8_ENABLE_SANDBOX
partition_alloc::PartitionAllocator& GetGeneralPartitionAllocator() {
static pdfium::base::NoDestructor<partition_alloc::PartitionAllocator>
@@ -97,13 +99,16 @@
static bool s_partition_allocators_initialized = false;
if (!s_partition_allocators_initialized) {
partition_alloc::PartitionAllocGlobalInit(FX_OutOfMemoryTerminate);
+#ifndef V8_ENABLE_SANDBOX
GetArrayBufferPartitionAllocator().init(kOptions);
+#endif // V8_ENABLE_SANDBOX
GetGeneralPartitionAllocator().init(kOptions);
GetStringPartitionAllocator().init(kOptions);
s_partition_allocators_initialized = true;
}
}
+#ifndef V8_ENABLE_SANDBOX
void* FX_ArrayBufferAllocate(size_t length) {
return GetArrayBufferPartitionAllocator().root()->AllocWithFlags(
partition_alloc::AllocFlags::kZeroFill, length, "FXArrayBuffer");
@@ -117,6 +122,7 @@
void FX_ArrayBufferFree(void* data) {
GetArrayBufferPartitionAllocator().root()->Free(data);
}
+#endif // V8_ENABLE_SANDBOX
void FX_Free(void* ptr) {
// TODO(palmer): Removing this check exposes crashes when PDFium callers