From 53cde131e977a3a640a3d55b2e6b35ac7461e08e Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Tue, 18 Jun 2019 14:37:09 -0700 Subject: [PATCH] Add missing ShallowClone implementation for SetType It turns out that SetType was missing a ShallowClone implementation. Which meant that when a SetType was cloned, a TableType was received (which has one less member). Which resulted in invalid memory accesses when using the clone. Thank you valgrind :) --- src/Type.cc | 13 +++++++++++++ src/Type.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/Type.cc b/src/Type.cc index fdcbddf9c7..f5a93c3315 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -484,6 +484,19 @@ SetType::SetType(TypeList* ind, ListExpr* arg_elements) : TableType(ind, 0) } } +SetType* SetType::ShallowClone() + { + // constructor only consumes indices when elements + // is set + if ( elements && indices ) + { + elements->Ref(); + indices->Ref(); + } + + return new SetType(indices, elements); + } + SetType::~SetType() { Unref(elements); diff --git a/src/Type.h b/src/Type.h index a97f7360c8..043ec5c928 100644 --- a/src/Type.h +++ b/src/Type.h @@ -381,6 +381,8 @@ public: SetType(TypeList* ind, ListExpr* arg_elements); ~SetType() override; + SetType* ShallowClone() override; + ListExpr* SetElements() const { return elements; } protected: