Fix StoreFromAddress and LoadFromAddress continuing with bad values after error (bug 6080, r=asherkin).

This commit is contained in:
Nicholas Hastings 2014-03-23 17:07:51 -04:00
parent 49d769282b
commit ee595978f8

View File

@ -682,11 +682,11 @@ static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params)
if (addr == NULL)
{
pContext->ThrowNativeError("Address cannot be null");
return pContext->ThrowNativeError("Address cannot be null");
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
}
NumberType size = static_cast<NumberType>(params[2]);
@ -699,10 +699,8 @@ static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params)
case NumberType_Int32:
return *reinterpret_cast<uint32_t*>(addr);
default:
pContext->ThrowNativeError("Invalid number types %d", size);
return pContext->ThrowNativeError("Invalid number types %d", size);
}
return 1;
}
@ -712,11 +710,11 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
if (addr == NULL)
{
pContext->ThrowNativeError("Address cannot be null");
return pContext->ThrowNativeError("Address cannot be null");
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
}
cell_t data = params[2];
@ -737,10 +735,10 @@ static cell_t StoreToAddress(IPluginContext *pContext, const cell_t *params)
*reinterpret_cast<uint32_t*>(addr) = data;
break;
default:
pContext->ThrowNativeError("Invalid number types %d", size);
return pContext->ThrowNativeError("Invalid number types %d", size);
}
return 1;
return 0;
}
REGISTER_NATIVES(coreNatives)