SCP: Return write failure (write 0 bytes) if malloc fails in sim_fwrite on a big-endian host. Fix #204

This commit is contained in:
Mark Pizzolato 2015-04-02 07:01:23 -07:00
parent 38eaee77d9
commit a8087ac4cc

View file

@ -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 */