From: Tor Didriksen Date: November 30 2012 10:36am Subject: bzr push into mysql-trunk branch (tor.didriksen:5131 to 5132) List-Archive: http://lists.mysql.com/commits/145419 Message-Id: <20121130103608.19459.77197.5132@atum07.no.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 5132 Tor Didriksen 2012-11-30 [merge] merge 5.6 => trunk modified: sql/sql_acl.cc 5131 Vasil Dimov 2012-11-30 [merge] Merge mysql-5.6 -> mysql-trunk modified: storage/innobase/handler/i_s.cc === modified file 'sql/sql_acl.cc' --- a/sql/sql_acl.cc 2012-11-29 11:57:19 +0000 +++ b/sql/sql_acl.cc 2012-11-30 10:31:27 +0000 @@ -11297,6 +11297,18 @@ void deinit_rsa_keys(void) g_rsa_keys.free_memory(); } +// Wraps a FILE handle, to ensure we always close it when returning. +class FileCloser +{ + FILE *m_file; +public: + FileCloser(FILE *to_be_closed) : m_file(to_be_closed) {} + ~FileCloser() + { + if (m_file != NULL) + fclose(m_file); + } +}; /** Loads the RSA key pair from disk and store them in a global variable. @@ -11351,6 +11363,7 @@ int init_rsa_keys(void) /* Don't return an error; server will still be able to operate. */ return 0; } + FileCloser close_priv(priv_key_file); if (strchr(auth_rsa_public_key_path, FN_LIBCHAR) != NULL || strchr(auth_rsa_public_key_path, FN_LIBCHAR2) != NULL) @@ -11373,6 +11386,7 @@ int init_rsa_keys(void) /* Don't return an error; server will still be able to operate. */ return 0; } + FileCloser close_public(public_key_file); RSA *rsa_private_key= RSA_new(); if (g_rsa_keys.set_private_key(PEM_read_RSAPrivateKey(priv_key_file, No bundle (reason: useless for push emails).