Convert some CPDF_ExpIntFunc getters to return spans.
Use spans to help enforce bound checking for GetBeginValues() and
GetEndValues(). Also mark these methods as Skia-only.
Change-Id: I7589cee0db26c7073f72e1d733eb29ae7d9fd837
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/97930
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_expintfunc.h b/core/fpdfapi/page/cpdf_expintfunc.h
index c31ad8b..d829456 100644
--- a/core/fpdfapi/page/cpdf_expintfunc.h
+++ b/core/fpdfapi/page/cpdf_expintfunc.h
@@ -12,6 +12,10 @@
#include "core/fpdfapi/page/cpdf_function.h"
+#if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
+#include "third_party/base/span.h"
+#endif
+
class CPDF_ExpIntFunc final : public CPDF_Function {
public:
CPDF_ExpIntFunc();
@@ -25,8 +29,11 @@
uint32_t GetOrigOutputs() const { return m_nOrigOutputs; }
float GetExponent() const { return m_Exponent; }
- const std::vector<float>& GetBeginValues() const { return m_BeginValues; }
- const std::vector<float>& GetEndValues() const { return m_EndValues; }
+
+#if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
+ pdfium::span<const float> GetBeginValues() const { return m_BeginValues; }
+ pdfium::span<const float> GetEndValues() const { return m_EndValues; }
+#endif
private:
uint32_t m_nOrigOutputs = 0;
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 80f3266..d153bc4 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -419,8 +419,8 @@
if (pFunc->GetOrigOutputs() != 3)
return false;
- auto begin_values = pFunc->GetBeginValues().begin();
- auto end_values = pFunc->GetEndValues().begin();
+ auto begin_values = pFunc->GetBeginValues();
+ auto end_values = pFunc->GetEndValues();
if (is_encode_reversed)
std::swap(begin_values, end_values);