summaryrefslogtreecommitdiff
path: root/src/literal.h
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-09-01 15:55:58 -0700
committerGitHub <noreply@github.com>2020-09-01 15:55:58 -0700
commit85234cb540c2b2863dfea6c20496dcb451df8889 (patch)
treea2475df8d4f79a4d04f43cb991b4a4a07b59b9c4 /src/literal.h
parentfecfa92d71633f8bb28bb97a60adc9b54998456f (diff)
downloadbinaryen-85234cb540c2b2863dfea6c20496dcb451df8889.tar.gz
binaryen-85234cb540c2b2863dfea6c20496dcb451df8889.tar.bz2
binaryen-85234cb540c2b2863dfea6c20496dcb451df8889.zip
Fix ExceptionPackage memory errors (#3088)
First, adds an explicit destructor call to fix a memory leak in `Literal::operator=` in which existing `ExceptionPackage`s would be silently dropped. Next, changes `Literal::getExceptionPackage` to return the `ExceptionPackage` by value to avoid a use-after-free bug in the interpreter that was surfaced by the new destructor call. A future improvement would be to switch to using `std::variant`. Fixes #3087.
Diffstat (limited to 'src/literal.h')
-rw-r--r--src/literal.h5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/literal.h b/src/literal.h
index 5c72bf96c..cffa9ab7d 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -135,10 +135,7 @@ public:
assert(type == Type::funcref);
return func;
}
- const ExceptionPackage& getExceptionPackage() const {
- assert(type == Type::exnref);
- return *exn.get();
- }
+ ExceptionPackage getExceptionPackage() const;
// careful!
int32_t* geti32Ptr() {