From ee595978f89f9be327d83125a5053acf92fe8f4d Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 23 Mar 2014 17:07:51 -0400 Subject: [PATCH] Fix StoreFromAddress and LoadFromAddress continuing with bad values after error (bug 6080, r=asherkin). --- core/smn_core.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/smn_core.cpp b/core/smn_core.cpp index b19900d83..4d301db42 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -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(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(params[2]); @@ -699,10 +699,8 @@ static cell_t LoadFromAddress(IPluginContext *pContext, const cell_t *params) case NumberType_Int32: return *reinterpret_cast(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(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(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)