From fa83b7df5a0711bf5f4a5162cc33b0a4123a53c7 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:06:13 +0000 Subject: fix(arrays): reject inverted bounds and check array allocation Constant inverted bounds are a compile error and other bounds are checked at run time. Allocation sizes use overflow-checked arithmetic, and a NULL malloc (including the BYVAL copy) reports that the array is too large. Co-Authored-By: Claude Sonnet 5.5 --- lib/CodeGen/ArrayParameters.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/CodeGen/ArrayParameters.cc') diff --git a/lib/CodeGen/ArrayParameters.cc b/lib/CodeGen/ArrayParameters.cc index 57cf6dd..57dc523 100644 --- a/lib/CodeGen/ArrayParameters.cc +++ b/lib/CodeGen/ArrayParameters.cc @@ -32,6 +32,7 @@ void ArrayHandler::bindArrayParameter(const std::string &Name, Value *TotalBytes = Builder->CreateMul(TotalElements, Meta.ElementSizeC, Name + "_copy_bytes"); Value *Copy = Builder->CreateCall(MallocFunc, TotalBytes, Name + "_copy"); + emitAllocCheck(Copy, Name, CG.DiagnosticLine); FunctionType *MemcpyType = FunctionType::get( PointerType::getUnqual(*TheContext), {PointerType::getUnqual(*TheContext), PointerType::getUnqual(*TheContext), -- cgit v1.3.1-4-g156e