Hi everybody, Subject says it all. Find patch attached to this email.
-- Best regards, Thilo Schulz -- libftdi - see http://www.intra2net.com/en/developer/libftdi for details. To unsubscribe send a mail to [email protected]
>From d426de6070ba4fcbcf800547ff1d8b9002daca22 Mon Sep 17 00:00:00 2001 From: Thilo Schulz <[email protected]> Date: Sat, 10 Oct 2015 13:06:04 +0200 Subject: [PATCH] Fix segfault crash if output file cannot be opened --- ftdi_eeprom/main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c index edcfad7..0d75c24 100644 --- a/ftdi_eeprom/main.c +++ b/ftdi_eeprom/main.c @@ -35,6 +35,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <errno.h> #include <confuse.h> #include <libusb.h> @@ -395,10 +396,15 @@ int main(int argc, char *argv[]) } if (filename != NULL && strlen(filename) > 0) { - FILE *fp = fopen (filename, "wb"); - fwrite (eeprom_buf, 1, my_eeprom_size, fp); - fclose (fp); + + if(fp) + { + fwrite(eeprom_buf, 1, my_eeprom_size, fp); + fclose(fp); + } + else + fprintf(stderr, "Could not open output file %s: %s\n", filename, strerror(errno)); } else { -- 2.1.4
