Skip to content

Commit 2a1b554

Browse files
committed
fix(DaedalusVm): handle pop_instance failure gracefully
1 parent cce5151 commit 2a1b554

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/DaedalusVm.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,16 @@ ZkDaedalusInstance* ZkDaedalusVm_popInstance(ZkDaedalusVm* slf) {
156156
ZKC_TRACE_FN();
157157
ZKC_CHECK_NULL(slf);
158158

159-
auto instance = slf->handle.pop_instance();
160-
if (instance == nullptr) {
161-
return nullptr;
162-
}
163-
164-
ZKC_RETURN_CATCH(new ZkDaedalusInstance(instance));
159+
try {
160+
auto instance = slf->handle.pop_instance();
161+
if (instance == nullptr) {
162+
return nullptr;
163+
}
164+
ZKC_RETURN_CATCH(new ZkDaedalusInstance(instance));
165+
} catch (zenkit::DaedalusScriptError const& e) {
166+
ZKC_LOG_ERROR("Failed to pop instance: %s", e.what());
167+
return nullptr;
168+
}
165169
}
166170

167171
ZkDaedalusInstance* ZkDaedalusVm_getGlobalSelf(ZkDaedalusVm* slf) {

0 commit comments

Comments
 (0)