From a8087ac4cc14072022b717b6d1ec6b4ad4086e34 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 2 Apr 2015 07:01:23 -0700 Subject: [PATCH] SCP: Return write failure (write 0 bytes) if malloc fails in sim_fwrite on a big-endian host. Fix #204 --- sim_fio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sim_fio.c b/sim_fio.c index 5e708516..8381674f 100644 --- a/sim_fio.c +++ b/sim_fio.c @@ -155,6 +155,8 @@ if ((size == 0) || (count == 0)) /* check arguments */ if (sim_end || (size == sizeof (char))) /* le or byte? */ return fwrite (bptr, size, count, fptr); /* done */ sim_flip = (unsigned char *)malloc(FLIP_SIZE); +if (!sim_flip) + return 0; nelem = FLIP_SIZE / size; /* elements in buffer */ nbuf = count / nelem; /* number buffers */ lcnt = count % nelem; /* count in last buf */