Attempt to fix attributes lookup and their visibility.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
2d50a64cac
commit
28e18bcb4b
24
engine/vm.c
24
engine/vm.c
|
@ -4209,10 +4209,23 @@ static sxi32 VmByteCodeExec(
|
||||||
SyHashEntry *pEntry;
|
SyHashEntry *pEntry;
|
||||||
/* Extract the target attribute */
|
/* Extract the target attribute */
|
||||||
if(sName.nByte > 0) {
|
if(sName.nByte > 0) {
|
||||||
pEntry = SyHashGet(&pThis->hAttr, (const void *)sName.zString, sName.nByte);
|
SyHashResetLoopCursor(&pThis->hAttr);
|
||||||
if(pEntry) {
|
while((pEntry = SyHashGetNextEntry(&pThis->hAttr)) != 0) {
|
||||||
/* Point to the attribute value */
|
|
||||||
pObjAttr = (VmClassAttr *)pEntry->pUserData;
|
pObjAttr = (VmClassAttr *)pEntry->pUserData;
|
||||||
|
if(SyStrncmp(pObjAttr->pAttr->sName.zString, sName.zString, sName.nByte) == 0) {
|
||||||
|
if(pNos->iFlags != MEMOBJ_PARENTOBJ && pObjAttr->pAttr->pClass == pClass) {
|
||||||
|
break;
|
||||||
|
} else if(pNos->iFlags != MEMOBJ_BASEOBJ && pObjAttr->pAttr->iProtection != PH7_CLASS_PROT_PRIVATE) {
|
||||||
|
SyHashEntry *pDerived = SyHashGet(&pClass->hDerived, (const void *)pObjAttr->pAttr->pClass->sName.zString, pObjAttr->pAttr->pClass->sName.nByte);
|
||||||
|
if(pDerived != 0) {
|
||||||
|
ph7_class *pSub = (ph7_class *)pDerived->pUserData;
|
||||||
|
if(pObjAttr->pAttr->pClass == pSub) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pObjAttr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pObjAttr == 0) {
|
if(pObjAttr == 0) {
|
||||||
|
@ -4231,7 +4244,7 @@ static sxi32 VmByteCodeExec(
|
||||||
if(pObjAttr) {
|
if(pObjAttr) {
|
||||||
ph7_value *pValue = 0; /* cc warning */
|
ph7_value *pValue = 0; /* cc warning */
|
||||||
/* Check attribute access */
|
/* Check attribute access */
|
||||||
if(VmClassMemberAccess(&(*pVm), pClass, &pObjAttr->pAttr->sName, pObjAttr->pAttr->iProtection, TRUE)) {
|
if(VmClassMemberAccess(&(*pVm), pClass, &pObjAttr->pAttr->sName, pObjAttr->pAttr->iProtection, FALSE)) {
|
||||||
/* Load attribute */
|
/* Load attribute */
|
||||||
pValue = (ph7_value *)SySetAt(&pVm->aMemObj, pObjAttr->nIdx);
|
pValue = (ph7_value *)SySetAt(&pVm->aMemObj, pObjAttr->nIdx);
|
||||||
if(pValue) {
|
if(pValue) {
|
||||||
|
@ -4251,6 +4264,9 @@ static sxi32 VmByteCodeExec(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
||||||
|
"Access to the class attribute '%z->%z' is forbidden", &pClass->sName, &pObjAttr->pAttr->sName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Safely unreference the object */
|
/* Safely unreference the object */
|
||||||
|
|
Loading…
Reference in New Issue