libftdi Archives

Subject: [PATCH 2/6] ftdi_eeprom: Fix segmentation fault after --flash_eeprom

From: Anders Larsen <al@xxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 9 Apr 2012 17:29:20 +0200
Allocate a buffer if it's not already available (hint: it was only allocated
by --read-eeprom)

Signed-off-by: Anders Larsen <al@xxxxxxxxxxx>
---
 ftdi_eeprom/main.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c
index 0ffffd7..94cd7ec 100644
--- a/ftdi_eeprom/main.c
+++ b/ftdi_eeprom/main.c
@@ -346,6 +346,8 @@ int main(int argc, char *argv[])
         else
             printf ("Writing to file: %s\n", filename);
 
+        if (eeprom_buf == NULL)
+            eeprom_buf = malloc(my_eeprom_size);
         ftdi_get_eeprom_buf(ftdi, eeprom_buf, my_eeprom_size);
 
         fwrite(eeprom_buf, my_eeprom_size, 1, fp);
-- 
1.7.0.4


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread