From 77798c73c5ce16ef355436816514d703dfc84464 Mon Sep 17 00:00:00 2001 From: louie Date: Sun, 1 Aug 2021 13:36:48 -0700 Subject: Fixed invalid config path crash --- read_cfg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'read_cfg.c') diff --git a/read_cfg.c b/read_cfg.c index 61ddce1..77c4381 100644 --- a/read_cfg.c +++ b/read_cfg.c @@ -32,7 +32,8 @@ bool hr = false; //turn foldCase (insensitive case searching) on or off; On by default bool fold_case = true; -void cfg_interp(char *path){ +//return false if invalid path +bool cfg_interp(char *path){ FILE *fp; char buffer[BUF_LEN]; GROUP **g; @@ -43,7 +44,10 @@ void cfg_interp(char *path){ int j; fp = fopen(path, "r"); - assert(fp != NULL); + if(fp == NULL){ + printf("Error: Invalid Configuration Path \"%s\"\n", path); + return false; + } //build the options array char **options = malloc(sizeof(char *) * OPTION_CNT); @@ -87,7 +91,7 @@ void cfg_interp(char *path){ */ fclose(fp); - return; + return true; } bool get_sort(){ -- cgit