From c664af6f6083061de32c48ef2aa69d8db86ae341 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 27 Jan 2015 12:22:42 +0100 Subject: [PATCH] mpegts mux dvb: fix the load sequence and possible memory leak --- src/input/mpegts/mpegts_mux_dvb.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/input/mpegts/mpegts_mux_dvb.c b/src/input/mpegts/mpegts_mux_dvb.c index 7784c613..7d81f6e9 100644 --- a/src/input/mpegts/mpegts_mux_dvb.c +++ b/src/input/mpegts/mpegts_mux_dvb.c @@ -649,11 +649,20 @@ dvb_mux_create0 } /* Create */ - if (!(mm = mpegts_mux_create0(calloc(1, sizeof(dvb_mux_t)), idc, uuid, - (mpegts_network_t*)ln, onid, tsid, conf))) - return NULL; + mm = calloc(1, sizeof(dvb_mux_t)); lm = (dvb_mux_t*)mm; + /* Defaults */ + lm->lm_tuning.dmc_fe_inversion = DVB_INVERSION_AUTO; + lm->lm_tuning.dmc_fe_pilot = DVB_PILOT_AUTO; + + /* Parent init and load config */ + if (!(mm = mpegts_mux_create0(mm, idc, uuid, + (mpegts_network_t*)ln, onid, tsid, conf))) { + free(mm); + return NULL; + } + /* Tuning */ if (dmc) memcpy(&lm->lm_tuning, dmc, sizeof(dvb_mux_conf_t)); @@ -665,12 +674,6 @@ dvb_mux_create0 lm->mm_config_save = dvb_mux_config_save; lm->mm_create_instances = dvb_mux_create_instances; - /* Defaults */ - if (dmc == NULL) { - lm->lm_tuning.dmc_fe_inversion = DVB_INVERSION_AUTO; - lm->lm_tuning.dmc_fe_pilot = DVB_PILOT_AUTO; - } - /* No config */ if (!conf) return lm;