diff options
author | woglinde <woglinde@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2015-04-12 20:51:23 +0000 |
---|---|---|
committer | woglinde <woglinde@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2015-04-12 20:51:23 +0000 |
commit | 98ef9173d21f48aac4fc8b669ba0156dcaf908a5 (patch) | |
tree | a8b5de5a03d38be8d84c50efd922b9743f71ead4 /navit | |
parent | dd308f6fbad2e46c47c1b21eab222a1c597e0a8e (diff) | |
download | navit-svn-98ef9173d21f48aac4fc8b669ba0156dcaf908a5.tar.gz |
Fix:core:close the filehandle when using a startup file, found by coverity
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@6070 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/start_real.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/navit/start_real.c b/navit/start_real.c index ddf88b88..e002cf93 100644 --- a/navit/start_real.c +++ b/navit/start_real.c @@ -213,13 +213,20 @@ int main_real(int argc, char * const* argv) conf.type=attr_config; conf.u.config=config; if (startup_file) { - FILE *f=fopen(startup_file,"r"); + FILE *f = fopen(startup_file,"r"); if (f) { char buffer[4096]; + int fclose_ret; while(fgets(buffer, sizeof(buffer), f)) { command_evaluate(&conf, buffer); } - } + fclose_ret = fclose(f); + if (fclose_ret != 0) { + dbg(lvl_error, "Could not close the specified startup file: %s\n", startup_file); + } + } else { + dbg(lvl_error, "Could not open the specified startup file: %s", startup_file); + } } if (command) { command_evaluate(&conf, command); |