Skip to content

Commit

Permalink
fix: resolve crash on accessing native property of uninitialized objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopodl committed Oct 3, 2023
1 parent 2ad901d commit 212c24f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions argon/vm/datatype/arobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 212c24f

Please sign in to comment.