Skip to content

Commit c8746ea

Browse files
author
Patrick Soquet
committed
XS: secaudit issue #26
1 parent e6e1ffb commit c8746ea

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

xs/sources/xsType.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -414,35 +414,44 @@ txBoolean fxOrdinaryDefineOwnProperty(txMachine* the, txSlot* instance, txID id,
414414
property->flag &= ~XS_DONT_ENUM_FLAG;
415415
}
416416
if (mask & XS_ACCESSOR_FLAG) {
417+
txSlot* getter = C_NULL;
418+
txSlot* setter = C_NULL;
417419
if (property->kind != XS_ACCESSOR_KIND) {
418420
property->kind = XS_ACCESSOR_KIND;
419421
property->value.accessor.getter = C_NULL;
420422
property->value.accessor.setter = C_NULL;
421423
}
422-
if (mask & XS_GETTER_FLAG) {
423-
txSlot* function = slot->value.accessor.getter;
424-
property->value.accessor.getter = function;
425-
if (mxIsFunction(function)) {
426-
if ((mask & XS_METHOD_FLAG) && ((function->flag & XS_MARK_FLAG) == 0)) {
427-
txSlot* home = mxFunctionInstanceHome(function);
424+
if (mask & XS_GETTER_FLAG)
425+
getter = property->value.accessor.getter = slot->value.accessor.getter;
426+
if (mask & XS_SETTER_FLAG)
427+
setter = property->value.accessor.setter = slot->value.accessor.setter;
428+
if (getter) {
429+
if (mxIsFunction(getter)) {
430+
if ((mask & XS_METHOD_FLAG) && ((getter->flag & XS_MARK_FLAG) == 0)) {
431+
txSlot* home = mxFunctionInstanceHome(getter);
428432
home->value.home.object = instance;
429433
}
430-
fxRenameFunction(the, slot->value.accessor.getter, id, index, mxID(_get), "get ");
434+
fxRenameFunction(the, getter, id, index, mxID(_get), "get ");
431435
}
432436
}
433-
if (mask & XS_SETTER_FLAG) {
434-
txSlot* function = slot->value.accessor.setter;
435-
property->value.accessor.setter = function;
436-
if (mxIsFunction(function)) {
437-
if ((mask & XS_METHOD_FLAG) && ((function->flag & XS_MARK_FLAG) == 0)) {
438-
txSlot* home = mxFunctionInstanceHome(slot->value.accessor.setter);
437+
if (setter) {
438+
if (mxIsFunction(setter)) {
439+
if ((mask & XS_METHOD_FLAG) && ((setter->flag & XS_MARK_FLAG) == 0)) {
440+
txSlot* home = mxFunctionInstanceHome(setter);
439441
home->value.home.object = instance;
440442
}
441-
fxRenameFunction(the, slot->value.accessor.setter, id, index, mxID(_set), "set ");
443+
fxRenameFunction(the, setter, id, index, mxID(_set), "set ");
442444
}
443445
}
444446
}
445447
else if ((mask & XS_DONT_SET_FLAG) || (slot->kind != XS_UNINITIALIZED_KIND)) {
448+
if (mask & XS_DONT_SET_FLAG) {
449+
if (slot->flag & XS_DONT_SET_FLAG) {
450+
property->flag |= XS_DONT_SET_FLAG;
451+
}
452+
else
453+
property->flag &= ~XS_DONT_SET_FLAG;
454+
}
446455
if (slot->kind != XS_UNINITIALIZED_KIND) {
447456
property->kind = slot->kind;
448457
property->value = slot->value;
@@ -457,13 +466,6 @@ txBoolean fxOrdinaryDefineOwnProperty(txMachine* the, txSlot* instance, txID id,
457466
}
458467
}
459468
}
460-
if (mask & XS_DONT_SET_FLAG) {
461-
if (slot->flag & XS_DONT_SET_FLAG) {
462-
property->flag |= XS_DONT_SET_FLAG;
463-
}
464-
else
465-
property->flag &= ~XS_DONT_SET_FLAG;
466-
}
467469
}
468470
return 1;
469471
}

0 commit comments

Comments
 (0)