From 21854ccdb250e6e81311b4317934e8c953b252a8 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Wed, 17 Feb 2010 18:31:48 -0800 Subject: Filename check and free allocated strings Make sure file is valid before we try to read it. Also free all the strings we allocate in various functions so we don't leak memory. Change-Id: Ica3c8dae992e73718c79c12ff5d7e315c290caea --- edify/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'edify/main.c') diff --git a/edify/main.c b/edify/main.c index 0e3610847..a2b74ad92 100644 --- a/edify/main.c +++ b/edify/main.c @@ -181,6 +181,10 @@ int main(int argc, char** argv) { } FILE* f = fopen(argv[1], "r"); + if (f == NULL) { + printf("%s: %s: No such file or directory\n", argv[0], argv[1]); + return 1; + } char buffer[8192]; int size = fread(buffer, 1, 8191, f); fclose(f); -- cgit v1.2.3