Author: ib Date: Thu Apr 24 14:50:14 2014 New Revision: 37168 Log: Rewrite add_vf(). Prefer calloc() to malloc(). As a result, vf_settings[1] doesn't need to be cleared. Additionally, check the result of the allocation. Modified: trunk/gui/interface.c Modified: trunk/gui/interface.c ============================================================================== --- trunk/gui/interface.c Thu Apr 24 14:44:33 2014 (r37167) +++ trunk/gui/interface.c Thu Apr 24 14:50:14 2014 (r37168) @@ -299,10 +299,13 @@ static void add_vf(const char *vf) memset(&vf_settings[i + 1], 0, sizeof(m_obj_settings_t)); } } else { - vf_settings = malloc(2 * sizeof(m_obj_settings_t)); + vf_settings = calloc(2, sizeof(m_obj_settings_t)); + + if (!vf_settings) + return; + vf_settings[0].name = strdup(vf); vf_settings[0].attribs = NULL; - vf_settings[1].name = NULL; } mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_AddingVideoFilter, vf);
On Thu, Apr 24, 2014 at 02:50:14PM +0200, ib wrote:
+ vf_settings = calloc(2, sizeof(m_obj_settings_t));
sizeof(*vf_settings) is usually preferred in MPlayer code.
participants (2)
-
ib -
Reimar Döffinger