diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2020-03-06 14:26:47 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2020-03-06 14:29:12 +0300 |
commit | 24a37b3c03f50411669ce26ab078de8980802ce3 (patch) | |
tree | 91fcc684836ffd1fd9f9272c954875c01e668f3a /intern | |
parent | e65f5c07b04e592dc7a5490ebc5f271d52729b48 (diff) |
Fix memory leak in the colorio fallback implementation.
We would previously not store the transforms that were added to the
group transform node. This would lead to pointer to allocated memory
being lost and not freed.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/opencolorio/fallback_impl.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc index 7042579a7eb..f5481b5d7cd 100644 --- a/intern/opencolorio/fallback_impl.cc +++ b/intern/opencolorio/fallback_impl.cc @@ -19,6 +19,7 @@ #include <algorithm> #include <cstring> +#include <vector> #include "MEM_guardedalloc.h" #include "BLI_math_color.h" @@ -56,7 +57,7 @@ struct FallbackTransform { { } - ~FallbackTransform() + virtual ~FallbackTransform() { delete linear_transform; delete display_transform; @@ -159,7 +160,17 @@ struct FallbackTransform { float matrix[16]; float offset[4]; - MEM_CXX_CLASS_ALLOC_FUNCS("FallbackProcessor"); + MEM_CXX_CLASS_ALLOC_FUNCS("FallbackTransform"); +}; + +struct FallbackGroupTransform : FallbackTransform { + ~FallbackGroupTransform() + { + for (auto transform : list) { + delete transform; + } + } + std::vector<FallbackTransform *> list; }; struct FallbackProcessor { @@ -565,9 +576,8 @@ void FallbackImpl::displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransform { } -void FallbackImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *dt) +void FallbackImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr * /*dt*/) { - MEM_freeN(dt); } OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data, @@ -597,7 +607,7 @@ void FallbackImpl::OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *id) OCIO_GroupTransformRcPtr *FallbackImpl::createGroupTransform(void) { - FallbackTransform *transform = new FallbackTransform(); + FallbackTransform *transform = new FallbackGroupTransform(); transform->type = TRANSFORM_UNKNOWN; return (OCIO_GroupTransformRcPtr *)transform; } @@ -607,9 +617,11 @@ void FallbackImpl::groupTransformSetDirection(OCIO_GroupTransformRcPtr * /*gt*/, { } -void FallbackImpl::groupTransformPushBack(OCIO_GroupTransformRcPtr * /*gt*/, - OCIO_ConstTransformRcPtr * /*transform*/) +void FallbackImpl::groupTransformPushBack(OCIO_GroupTransformRcPtr *gt, + OCIO_ConstTransformRcPtr *transform) { + FallbackGroupTransform *group = (FallbackGroupTransform *)gt; + group->list.push_back((FallbackTransform *)transform); } void FallbackImpl::groupTransformRelease(OCIO_GroupTransformRcPtr * /*gt*/) |