ftdi_eeprom: Fix segmentation fault after --flash_eeprom
authorAnders Larsen <al@alarsen.net>
Mon, 9 Apr 2012 15:29:20 +0000 (17:29 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 13 Apr 2012 12:46:28 +0000 (14:46 +0200)
Allocate a buffer if it's not already available (hint: it was only allocated
by --read-eeprom)

Signed-off-by: Anders Larsen <al@alarsen.net>

ftdi_eeprom/main.c

index 0ffffd7..94cd7ec 100644 (file)
@@ -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);