1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[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
This commit is contained in:
Lang Hames 2018-11-20 01:01:26 +00:00
parent d550ec3daa
commit 75b432e448
2 changed files with 12 additions and 1 deletions

View File

@ -227,7 +227,8 @@ static bool ffiInvoke(RawFunc Fn, Function *F, ArrayRef<GenericValue> 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<uint8_t, 128> ret;
if (RetTy->getTypeID() != Type::VoidTyID)
ret.resize(TD.getTypeStoreSize(RetTy));

View File

@ -0,0 +1,10 @@
; RUN: %lli -force-interpreter %s
declare void @exit(i32)
declare i32 @rand()
define i32 @main() {
%ret = call i32 @rand()
call void @exit(i32 0)
ret i32 %ret
}