From 54ef9c9508f582046663db9a8101a3a542003f36 Mon Sep 17 00:00:00 2001 From: TitanMKD Date: Fri, 7 Jun 2013 19:37:37 +0200 Subject: [PATCH] hackrf_spiflash added checks & error on fileopen() error for read & write. --- host/hackrf-tools/src/hackrf_spiflash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/host/hackrf-tools/src/hackrf_spiflash.c b/host/hackrf-tools/src/hackrf_spiflash.c index 6a6d6880..f97f2875 100644 --- a/host/hackrf-tools/src/hackrf_spiflash.c +++ b/host/hackrf-tools/src/hackrf_spiflash.c @@ -158,6 +158,11 @@ int main(int argc, char** argv) if( write ) { fd = fopen(path, "rb"); + if(fd == NULL) + { + printf("Error to open file %s\n", path); + return EXIT_FAILURE; + } /* Get size of the file */ fseek(fd, 0, SEEK_END); /* Not really portable but work on major OS Linux/Win32 */ length = ftell(fd); @@ -185,6 +190,11 @@ int main(int argc, char** argv) if (read) { fd = fopen(path, "wb"); + if(fd == NULL) + { + printf("Error to open file %s\n", path); + return EXIT_FAILURE; + } } if (fd == NULL) {