fix: Add another address check for creating functions

This commit is contained in:
Teal Bauer 2025-05-22 14:25:09 +02:00
parent 58f22316bd
commit 8aded2e6c3

View File

@ -509,6 +509,12 @@ public class FunctionEndpoints extends AbstractEndpoint {
return; return;
} }
// Check if address is in a valid memory block
if (program.getMemory().getBlock(address) == null) {
sendErrorResponse(exchange, 400, "Address is not in a defined memory block: " + addressStr, "INVALID_ADDRESS");
return;
}
// Check if function already exists // Check if function already exists
if (program.getFunctionManager().getFunctionAt(address) != null) { if (program.getFunctionManager().getFunctionAt(address) != null) {
sendErrorResponse(exchange, 409, "Function already exists at address: " + addressStr, "FUNCTION_EXISTS"); sendErrorResponse(exchange, 409, "Function already exists at address: " + addressStr, "FUNCTION_EXISTS");