From 8307fb23bd5646568044cb75abc5e505c47d312a Mon Sep 17 00:00:00 2001 From: Jia Zhouyang Date: Thu, 1 Mar 2018 16:25:36 +0800 Subject: [PATCH] MDEV-15550 Add error handling for fopen Print error message and return when fopen fails. Closes #634 --- client/mysql_plugin.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index 81677ad551f..d297f3cd03e 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -365,6 +365,12 @@ static int get_default_values() } /* Now open the file and read the defaults we want. */ file= fopen(defaults_file, "r"); + if (file == NULL) + { + fprintf(stderr, "ERROR: failed to open file %s: %s.\n", defaults_file, + strerror(errno)); + goto exit; + } while (fgets(line, FN_REFLEN, file) != NULL) { char *value= 0;