diff options
Diffstat (limited to 'ft2232_spi.c')
-rw-r--r-- | ft2232_spi.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ft2232_spi.c b/ft2232_spi.c index 520eb6e1..9f4c7f03 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -468,8 +468,8 @@ static int ft2232_spi_send_command(struct flashctx *flash, static unsigned char *buf = NULL; /* failed is special. We use bitwise ops, but it is essentially bool. */ int i = 0, ret = 0, failed = 0; - int bufsize; - static int oldbufsize = 0; + size_t bufsize; + static size_t oldbufsize = 0; if (writecnt > 65536 || readcnt > 65536) return SPI_INVALID_LENGTH; @@ -477,7 +477,7 @@ static int ft2232_spi_send_command(struct flashctx *flash, /* buf is not used for the response from the chip. */ bufsize = max(writecnt + 9, 260 + 9); /* Never shrink. realloc() calls are expensive. */ - if (bufsize > oldbufsize) { + if (!buf || bufsize > oldbufsize) { buf = realloc(buf, bufsize); if (!buf) { msg_perr("Out of memory!\n"); |