From 212c24f2e223ba66e5e85d158b0a4871ddde8675 Mon Sep 17 00:00:00 2001 From: jacopodl Date: Wed, 4 Oct 2023 00:39:25 +0200 Subject: [PATCH] fix: resolve crash on accessing native property of uninitialized objects --- argon/vm/datatype/arobject.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/argon/vm/datatype/arobject.cpp b/argon/vm/datatype/arobject.cpp index f79502ae..dd115548 100644 --- a/argon/vm/datatype/arobject.cpp +++ b/argon/vm/datatype/arobject.cpp @@ -97,6 +97,13 @@ ArObject *type_get_attr(const ArObject *self, ArObject *key, bool static_attr) { } if (AR_TYPEOF(ret, type_native_wrapper_)) { + if (static_attr) { + ErrorFormat(kAccessViolationError[0], kAccessViolationError[2], + ARGON_RAW_STRING((String *) key), ((TypeInfo *) self)->name); + + return nullptr; + } + auto *value = NativeWrapperGet((NativeWrapper *) ret, self); Release(ret); @@ -197,6 +204,13 @@ bool type_set_attr(ArObject *self, ArObject *key, ArObject *value, bool static_a } if (AR_TYPEOF(current, type_native_wrapper_)) { + if (static_attr) { + ErrorFormat(kAccessViolationError[0], kAccessViolationError[2], + ARGON_RAW_STRING((String *) key), ((TypeInfo *) self)->name); + + return false; + } + auto ok = NativeWrapperSet((NativeWrapper *) current, self, value); Release(current);