diff options
| author | 2019-02-15 14:00:53 -0800 | |
|---|---|---|
| committer | 2019-02-15 14:07:46 -0800 | |
| commit | 20c825ae6066f39d9d0cdec2b1c5a42db8cad36b (patch) | |
| tree | 2d3f2ffda23019f258c912ab9cfcd7d2b1612500 | |
| parent | b2069ebab1de906ed02383dcd6467f3eb184b53e (diff) | |
Fix createLut in ColorSpace.
Previously createLut returns unique_ptr<float3>, which calls delete when it's
destroyed. However, the actual allocation happens using new float3[size * size
* size], which should cal delete [] when it's destroyed. This patch changes the
type to float3[] such that delete [] is called when it's destroyed.
BUG: 112717608
Test: N/A
Change-Id: Ida0671e33c0659c31d599eacc12fffbe35923876
| -rw-r--r-- | libs/ui/ColorSpace.cpp | 7 | ||||
| -rw-r--r-- | libs/ui/include/ui/ColorSpace.h | 4 |
2 files changed, 5 insertions, 6 deletions
diff --git a/libs/ui/ColorSpace.cpp b/libs/ui/ColorSpace.cpp index 5b4bf2353e..7a14af1c9d 100644 --- a/libs/ui/ColorSpace.cpp +++ b/libs/ui/ColorSpace.cpp @@ -351,13 +351,12 @@ const ColorSpace ColorSpace::ACEScg() { }; } -std::unique_ptr<float3> ColorSpace::createLUT(uint32_t size, - const ColorSpace& src, const ColorSpace& dst) { - +std::unique_ptr<float3[]> ColorSpace::createLUT(uint32_t size, const ColorSpace& src, + const ColorSpace& dst) { size = clamp(size, 2u, 256u); float m = 1.0f / float(size - 1); - std::unique_ptr<float3> lut(new float3[size * size * size]); + std::unique_ptr<float3[]> lut(new float3[size * size * size]); float3* data = lut.get(); ColorSpaceConnector connector(src, dst); diff --git a/libs/ui/include/ui/ColorSpace.h b/libs/ui/include/ui/ColorSpace.h index 8ccf6d36e5..241ec106c0 100644 --- a/libs/ui/include/ui/ColorSpace.h +++ b/libs/ui/include/ui/ColorSpace.h @@ -250,8 +250,8 @@ public: // axis is thus already flipped // The source color space must define its values in the domain [0..1] // The generated LUT transforms from gamma space to gamma space - static std::unique_ptr<float3> createLUT(uint32_t size, - const ColorSpace& src, const ColorSpace& dst); + static std::unique_ptr<float3[]> createLUT(uint32_t size, const ColorSpace& src, + const ColorSpace& dst); private: static constexpr mat3 computeXYZMatrix( |