mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-28 14:36:34 +00:00
Fix an assertion abort on sparc. malloc(0) is allowed to
return NULL. llvm-svn: 42871
This commit is contained in:
parent
d47210011e
commit
0fb7aa568a
@ -24,6 +24,7 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
STATISTIC(NumDynamicInsts, "Number of dynamic instructions executed");
|
STATISTIC(NumDynamicInsts, "Number of dynamic instructions executed");
|
||||||
@ -747,7 +748,8 @@ void Interpreter::visitAllocationInst(AllocationInst &I) {
|
|||||||
|
|
||||||
unsigned TypeSize = (size_t)TD.getTypeSize(Ty);
|
unsigned TypeSize = (size_t)TD.getTypeSize(Ty);
|
||||||
|
|
||||||
unsigned MemToAlloc = NumElements * TypeSize;
|
// Avoid malloc-ing zero bytes, use max()...
|
||||||
|
unsigned MemToAlloc = std::max(1U, NumElements * TypeSize);
|
||||||
|
|
||||||
// Allocate enough memory to hold the type...
|
// Allocate enough memory to hold the type...
|
||||||
void *Memory = malloc(MemToAlloc);
|
void *Memory = malloc(MemToAlloc);
|
||||||
|
Loading…
Reference in New Issue
Block a user