1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Better error handling in stack serialization (#664)

This commit is contained in:
SpyCheese 2023-04-02 14:27:31 +00:00 committed by GitHub
parent 3a30d6f319
commit eabcb6a8e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -908,6 +908,7 @@ bool Stack::serialize(vm::CellBuilder& cb, int mode) const {
if (vsi && !vsi->register_op()) { if (vsi && !vsi->register_op()) {
return false; return false;
} }
try {
// vm_stack#_ depth:(## 24) stack:(VmStackList depth) = VmStack; // vm_stack#_ depth:(## 24) stack:(VmStackList depth) = VmStack;
unsigned n = depth(); unsigned n = depth();
if (!cb.store_ulong_rchk_bool(n, 24)) { // vm_stack#_ depth:(## 24) if (!cb.store_ulong_rchk_bool(n, 24)) { // vm_stack#_ depth:(## 24)
@ -925,6 +926,11 @@ bool Stack::serialize(vm::CellBuilder& cb, int mode) const {
} }
} }
return cb.store_ref_bool(std::move(rest)) && stack[n - 1].serialize(cb, mode); return cb.store_ref_bool(std::move(rest)) && stack[n - 1].serialize(cb, mode);
} catch (CellBuilder::CellCreateError) {
return false;
} catch (CellBuilder::CellWriteError) {
return false;
}
} }
bool Stack::deserialize(vm::CellSlice& cs, int mode) { bool Stack::deserialize(vm::CellSlice& cs, int mode) {