From a4d5b34f73e4cde7dec3193157285be5de846e74 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 20 Nov 2018 01:01:26 +0000 Subject: [ExecutionEngine][Interpreter] Fix out-of-bounds array access. If args is empty then accesing element 0 is illegal. https://reviews.llvm.org/D53556 Patch by Eugene Sharygin. Thanks Eugene! llvm-svn: 347281 --- llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib') diff --git a/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 64dca930722..044d9b7f27a 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -227,7 +227,8 @@ static bool ffiInvoke(RawFunc Fn, Function *F, ArrayRef ArgVals, Type *RetTy = FTy->getReturnType(); ffi_type *rtype = ffiTypeFor(RetTy); - if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NumArgs, rtype, &args[0]) == FFI_OK) { + if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, NumArgs, rtype, args.data()) == + FFI_OK) { SmallVector ret; if (RetTy->getTypeID() != Type::VoidTyID) ret.resize(TD.getTypeStoreSize(RetTy)); -- cgit v1.2.3