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:
parent
d550ec3daa
commit
75b432e448
@ -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));
|
||||
|
10
test/ExecutionEngine/Interpreter/call-no-args.ll
Normal file
10
test/ExecutionEngine/Interpreter/call-no-args.ll
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user