PH7_VmMemoryError() always breaks script execution.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
b7e3ad9f46
commit
a5ee2d75eb
50
engine/vm.c
50
engine/vm.c
|
@ -634,7 +634,6 @@ static sxi32 VmMountUserClass(
|
||||||
pMemObj = PH7_ReserveMemObj(&(*pVm));
|
pMemObj = PH7_ReserveMemObj(&(*pVm));
|
||||||
if(pMemObj == 0) {
|
if(pMemObj == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
return SXERR_MEM;
|
|
||||||
}
|
}
|
||||||
if(SySetUsed(&pAttr->aByteCode) > 0) {
|
if(SySetUsed(&pAttr->aByteCode) > 0) {
|
||||||
/* Initialize attribute default value (any complex expression) */
|
/* Initialize attribute default value (any complex expression) */
|
||||||
|
@ -2700,7 +2699,6 @@ static sxi32 VmByteCodeExec(
|
||||||
zName = (char *)SyMemBackendAlloc(&pVm->sAllocator, sizeof("[closure_]") + 64);
|
zName = (char *)SyMemBackendAlloc(&pVm->sAllocator, sizeof("[closure_]") + 64);
|
||||||
if(pClosure == 0 || zName == 0) {
|
if(pClosure == 0 || zName == 0) {
|
||||||
PH7_VmMemoryError(pVm);
|
PH7_VmMemoryError(pVm);
|
||||||
goto Abort;
|
|
||||||
}
|
}
|
||||||
mLen = SyBufferFormat(zName, sizeof("[closure_]") + 64, "[closure_%d]", pVm->closure_cnt++);
|
mLen = SyBufferFormat(zName, sizeof("[closure_]") + 64, "[closure_%d]", pVm->closure_cnt++);
|
||||||
while(SyHashGet(&pVm->hFunction, zName, mLen) != 0 && mLen < (sizeof("[closure_]") + 60/* not 64 */)) {
|
while(SyHashGet(&pVm->hFunction, zName, mLen) != 0 && mLen < (sizeof("[closure_]") + 60/* not 64 */)) {
|
||||||
|
@ -2895,7 +2893,6 @@ static sxi32 VmByteCodeExec(
|
||||||
rc = PH7_MemObjToHashmap(pObj);
|
rc = PH7_MemObjToHashmap(pObj);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
goto Abort;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pMap = (ph7_hashmap *)pObj->x.pOther;
|
pMap = (ph7_hashmap *)pObj->x.pOther;
|
||||||
|
@ -4046,7 +4043,6 @@ static sxi32 VmByteCodeExec(
|
||||||
pObj = VmExtractMemObj(&(*pVm), &sName, FALSE, TRUE);
|
pObj = VmExtractMemObj(&(*pVm), &sName, FALSE, TRUE);
|
||||||
if(pObj == 0) {
|
if(pObj == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
goto Abort;
|
|
||||||
}
|
}
|
||||||
/* Perform the store operation */
|
/* Perform the store operation */
|
||||||
PH7_MemObjStore(pTos, pObj);
|
PH7_MemObjStore(pTos, pObj);
|
||||||
|
@ -4084,7 +4080,6 @@ static sxi32 VmByteCodeExec(
|
||||||
rc = VmEnterFrame(&(*pVm), 0, 0, &pFrame);
|
rc = VmEnterFrame(&(*pVm), 0, 0, &pFrame);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
goto Abort;
|
|
||||||
}
|
}
|
||||||
/* Mark the special frame */
|
/* Mark the special frame */
|
||||||
pFrame->iFlags |= VM_FRAME_EXCEPTION;
|
pFrame->iFlags |= VM_FRAME_EXCEPTION;
|
||||||
|
@ -4299,8 +4294,6 @@ static sxi32 VmByteCodeExec(
|
||||||
pStep = (ph7_foreach_step *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(ph7_foreach_step));
|
pStep = (ph7_foreach_step *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(ph7_foreach_step));
|
||||||
if(pStep == 0) {
|
if(pStep == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
/* Jump out of the loop */
|
|
||||||
pc = pInstr->iP2 - 1;
|
|
||||||
} else {
|
} else {
|
||||||
/* Zero the structure */
|
/* Zero the structure */
|
||||||
SyZero(pStep, sizeof(ph7_foreach_step));
|
SyZero(pStep, sizeof(ph7_foreach_step));
|
||||||
|
@ -4326,9 +4319,6 @@ static sxi32 VmByteCodeExec(
|
||||||
}
|
}
|
||||||
if(SXRET_OK != SySetPut(&pInfo->aStep, (const void *)&pStep)) {
|
if(SXRET_OK != SySetPut(&pInfo->aStep, (const void *)&pStep)) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
SyMemBackendPoolFree(&pVm->sAllocator, pStep);
|
|
||||||
/* Jump out of the loop */
|
|
||||||
pc = pInstr->iP2 - 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VmPopOperand(&pTos, 1);
|
VmPopOperand(&pTos, 1);
|
||||||
|
@ -4727,12 +4717,6 @@ static sxi32 VmByteCodeExec(
|
||||||
pNew = PH7_NewClassInstance(&(*pVm), pClass);
|
pNew = PH7_NewClassInstance(&(*pVm), pClass);
|
||||||
if(pNew == 0) {
|
if(pNew == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
PH7_MemObjRelease(pTos);
|
|
||||||
if(pInstr->iP1 > 0) {
|
|
||||||
/* Pop given arguments */
|
|
||||||
VmPopOperand(&pTos, pInstr->iP1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* Check if a constructor is available */
|
/* Check if a constructor is available */
|
||||||
pCons = PH7_ClassExtractMethod(pClass, "__construct", sizeof("__construct") - 1);
|
pCons = PH7_ClassExtractMethod(pClass, "__construct", sizeof("__construct") - 1);
|
||||||
|
@ -5010,13 +4994,6 @@ static sxi32 VmByteCodeExec(
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
/* Raise exception: Out of memory */
|
/* Raise exception: Out of memory */
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
/* Pop given arguments */
|
|
||||||
if(pInstr->iP1 > 0) {
|
|
||||||
VmPopOperand(&pTos, pInstr->iP1);
|
|
||||||
}
|
|
||||||
/* Assume a null return value so that the program continue it's execution normally */
|
|
||||||
PH7_MemObjRelease(pTos);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if((pVmFunc->iFlags & VM_FUNC_CLASS_METHOD) && pThis) {
|
if((pVmFunc->iFlags & VM_FUNC_CLASS_METHOD) && pThis) {
|
||||||
/* Install the '$this' variable */
|
/* Install the '$this' variable */
|
||||||
|
@ -5219,10 +5196,6 @@ static sxi32 VmByteCodeExec(
|
||||||
if(pFrameStack == 0) {
|
if(pFrameStack == 0) {
|
||||||
/* Raise exception: Out of memory */
|
/* Raise exception: Out of memory */
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
if(pInstr->iP1 > 0) {
|
|
||||||
VmPopOperand(&pTos, pInstr->iP1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if(pSelf) {
|
if(pSelf) {
|
||||||
/* Push class name */
|
/* Push class name */
|
||||||
|
@ -7125,7 +7098,6 @@ PH7_PRIVATE sxi32 PH7_VmCallClassMethod(
|
||||||
aStack = VmNewOperandStack(&(*pVm), 2/* Method name + Aux data */ + nArg);
|
aStack = VmNewOperandStack(&(*pVm), 2/* Method name + Aux data */ + nArg);
|
||||||
if(aStack == 0) {
|
if(aStack == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
return SXERR_MEM;
|
|
||||||
}
|
}
|
||||||
/* Fill the operand stack with the given arguments */
|
/* Fill the operand stack with the given arguments */
|
||||||
for(i = 0 ; i < nArg ; i++) {
|
for(i = 0 ; i < nArg ; i++) {
|
||||||
|
@ -7262,11 +7234,6 @@ PH7_PRIVATE sxi32 PH7_VmCallUserFunction(
|
||||||
aStack = VmNewOperandStack(&(*pVm), 1 + nArg);
|
aStack = VmNewOperandStack(&(*pVm), 1 + nArg);
|
||||||
if(aStack == 0) {
|
if(aStack == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
if(pResult) {
|
|
||||||
/* Assume a null return value */
|
|
||||||
PH7_MemObjRelease(pResult);
|
|
||||||
}
|
|
||||||
return SXERR_MEM;
|
|
||||||
}
|
}
|
||||||
/* Fill the operand stack with the given arguments */
|
/* Fill the operand stack with the given arguments */
|
||||||
for(i = 0 ; i < nArg ; i++) {
|
for(i = 0 ; i < nArg ; i++) {
|
||||||
|
@ -7496,8 +7463,6 @@ static int vm_builtin_define(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pValue = (ph7_value *)SyMemBackendPoolAlloc(&pCtx->pVm->sAllocator, sizeof(ph7_value));
|
pValue = (ph7_value *)SyMemBackendPoolAlloc(&pCtx->pVm->sAllocator, sizeof(ph7_value));
|
||||||
if(pValue == 0) {
|
if(pValue == 0) {
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
ph7_result_bool(pCtx, 0);
|
|
||||||
return SXRET_OK;
|
|
||||||
}
|
}
|
||||||
/* Initialize the memory object */
|
/* Initialize the memory object */
|
||||||
PH7_MemObjInit(pCtx->pVm, pValue);
|
PH7_MemObjInit(pCtx->pVm, pValue);
|
||||||
|
@ -7506,8 +7471,6 @@ static int vm_builtin_define(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
SyMemBackendPoolFree(&pCtx->pVm->sAllocator, pValue);
|
SyMemBackendPoolFree(&pCtx->pVm->sAllocator, pValue);
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
ph7_result_bool(pCtx, 0);
|
|
||||||
return SXRET_OK;
|
|
||||||
}
|
}
|
||||||
/* Duplicate constant value */
|
/* Duplicate constant value */
|
||||||
PH7_MemObjStore(apArg[1], pValue);
|
PH7_MemObjStore(apArg[1], pValue);
|
||||||
|
@ -8227,7 +8190,6 @@ static int vm_builtin_random_bytes(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zBuf = SyMemBackendPoolAlloc(&pCtx->pVm->sAllocator, iLen);
|
zBuf = SyMemBackendPoolAlloc(&pCtx->pVm->sAllocator, iLen);
|
||||||
if(zBuf == 0) {
|
if(zBuf == 0) {
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
return SXERR_MEM;
|
|
||||||
}
|
}
|
||||||
PH7_VmRandomBytes(pCtx->pVm, zBuf, iLen);
|
PH7_VmRandomBytes(pCtx->pVm, zBuf, iLen);
|
||||||
ph7_result_string(pCtx, (char *)zBuf, iLen);
|
ph7_result_string(pCtx, (char *)zBuf, iLen);
|
||||||
|
@ -9028,8 +8990,6 @@ static int vm_builtin_debug_backtrace(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
pArray = ph7_context_new_array(pCtx);
|
pArray = ph7_context_new_array(pCtx);
|
||||||
if(!pArray) {
|
if(!pArray) {
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
ph7_result_null(pCtx);
|
|
||||||
return PH7_OK;
|
|
||||||
}
|
}
|
||||||
/* Iterate through debug frames */
|
/* Iterate through debug frames */
|
||||||
while(SySetGetNextEntry(&pDebug, (void **)&pTrace) == SXRET_OK) {
|
while(SySetGetNextEntry(&pDebug, (void **)&pTrace) == SXRET_OK) {
|
||||||
|
@ -9040,8 +9000,6 @@ static int vm_builtin_debug_backtrace(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
pValue = ph7_context_new_scalar(pCtx);
|
pValue = ph7_context_new_scalar(pCtx);
|
||||||
if(pArg == 0 || pSubArray == 0 || pValue == 0) {
|
if(pArg == 0 || pSubArray == 0 || pValue == 0) {
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
ph7_result_null(pCtx);
|
|
||||||
return PH7_OK;
|
|
||||||
}
|
}
|
||||||
/* Extract file name and line */
|
/* Extract file name and line */
|
||||||
ph7_value_int(pValue, pTrace->nLine);
|
ph7_value_int(pValue, pTrace->nLine);
|
||||||
|
@ -9571,9 +9529,6 @@ static int vm_builtin_parse_url(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
if(pArray == 0 || pValue == 0) {
|
if(pArray == 0 || pValue == 0) {
|
||||||
/* Out of memory */
|
/* Out of memory */
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
/* Return false */
|
|
||||||
ph7_result_bool(pCtx, 0);
|
|
||||||
return PH7_OK;
|
|
||||||
}
|
}
|
||||||
/* Fill the array */
|
/* Fill the array */
|
||||||
pComp = &sURI.sScheme;
|
pComp = &sURI.sScheme;
|
||||||
|
@ -9728,9 +9683,6 @@ static int vm_builtin_compact(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(pArray == 0) {
|
if(pArray == 0) {
|
||||||
/* Out of memory */
|
/* Out of memory */
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
/* Return NULL */
|
|
||||||
ph7_result_null(pCtx);
|
|
||||||
return PH7_OK;
|
|
||||||
}
|
}
|
||||||
/* Perform the requested operation */
|
/* Perform the requested operation */
|
||||||
for(i = 0 ; i < nArg ; i++) {
|
for(i = 0 ; i < nArg ; i++) {
|
||||||
|
@ -10673,8 +10625,6 @@ static int vm_builtin_getopt(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pWorker = ph7_context_new_scalar(pCtx);
|
pWorker = ph7_context_new_scalar(pCtx);
|
||||||
if(pArray == 0 || pWorker == 0) {
|
if(pArray == 0 || pWorker == 0) {
|
||||||
PH7_VmMemoryError(pCtx->pVm);
|
PH7_VmMemoryError(pCtx->pVm);
|
||||||
ph7_result_bool(pCtx, 0);
|
|
||||||
return PH7_OK;
|
|
||||||
}
|
}
|
||||||
if(SyBlobLength(pArg) < 1) {
|
if(SyBlobLength(pArg) < 1) {
|
||||||
/* Empty command line,return the empty array*/
|
/* Empty command line,return the empty array*/
|
||||||
|
|
Loading…
Reference in New Issue