[MPlayer-cvslog] r37908 - trunk/mp_msg.c
reimar
subversion at mplayerhq.hu
Wed Jan 4 22:00:11 EET 2017
Author: reimar
Date: Wed Jan 4 22:00:10 2017
New Revision: 37908
Log:
mp_msg.c: Fix leaking get_term_charset return value.
The leak is not particularly relevant, but the
4 lines of extra code should to be worth it to avoid
explaining/analyzing why the leak doesn't matter
over and over again.
Fixes part of trac issue #2311.
Modified:
trunk/mp_msg.c
Modified: trunk/mp_msg.c
==============================================================================
--- trunk/mp_msg.c Wed Jan 4 17:47:52 2017 (r37907)
+++ trunk/mp_msg.c Wed Jan 4 22:00:10 2017 (r37908)
@@ -42,6 +42,9 @@ int mp_msg_color = 0;
int mp_msg_module = 0;
#ifdef CONFIG_ICONV
char *mp_msg_charset = NULL;
+// only used to simplify freeing get_term_charset
+// result, even when it was overwritten by command-line options.
+char *term_charset_ptr_to_free = NULL;
static char *old_charset = NULL;
static iconv_t msgiconv;
static iconv_t inv_msgiconv = (iconv_t)(-1);
@@ -86,8 +89,10 @@ void mp_msg_init(void){
mp_msg_levels[MSGT_IDENTIFY] = -1; // no -identify output by default
#ifdef CONFIG_ICONV
mp_msg_charset = getenv("MPLAYER_CHARSET");
- if (!mp_msg_charset)
- mp_msg_charset = get_term_charset();
+ if (!mp_msg_charset) {
+ free(term_charset_ptr_to_free); // could assert that is is NULL instead
+ mp_msg_charset = term_charset_ptr_to_free = get_term_charset();
+ }
#endif
}
@@ -99,6 +104,8 @@ void mp_msg_uninit(void)
iconv_close(msgiconv);
}
if (inv_msgiconv != (iconv_t)(-1)) iconv_close(inv_msgiconv);
+ free(term_charset_ptr_to_free);
+ term_charset_ptr_to_free = NULL;
#endif
}
More information about the MPlayer-cvslog
mailing list