From 692ac873ccf2ea3a5091566ed9e2d027d4825eda Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Fri, 2 Aug 2019 11:21:42 -0700 Subject: a few fixes for audio track name handling fixes a memory leak makes name const --- libhb/common.c | 4 ++-- libhb/common.h | 4 ++-- libhb/hb_json.c | 5 +---- libhb/muxavformat.c | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) (limited to 'libhb') diff --git a/libhb/common.c b/libhb/common.c index 1602b4ed0..e21590fa2 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -4685,8 +4685,8 @@ void hb_audio_close( hb_audio_t **audio ) { if ( audio && *audio ) { - free((*audio)->config.in.name); - free((*audio)->config.out.name); + free((char*)(*audio)->config.in.name); + free((char*)(*audio)->config.out.name); free(*audio); *audio = NULL; } diff --git a/libhb/common.h b/libhb/common.h index 098ed78cf..e7c9b2b5f 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -831,7 +831,7 @@ struct hb_audio_config_s double gain; /* Gain (in dB), negative is quieter */ int normalize_mix_level; /* mix level normalization (boolean) */ int dither_method; /* dither algorithm */ - char * name; /* Output track name */ + const char * name; /* Output track name */ } out; /* Input */ @@ -857,7 +857,7 @@ struct hb_audio_config_s * These samples should be dropped * when decoding */ PRIVATE hb_rational_t timebase; - PRIVATE char * name; + PRIVATE const char * name; } in; struct diff --git a/libhb/hb_json.c b/libhb/hb_json.c index f69a1e322..08e9400a0 100644 --- a/libhb/hb_json.c +++ b/libhb/hb_json.c @@ -1538,10 +1538,7 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) audio.out.dither_method = hb_value_get_int(dither); } } - if (name != NULL && name[0] != 0) - { - audio.out.name = strdup(name); - } + audio.out.name = name; if (audio.in.track >= 0) { audio.out.track = ii; diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c index 8ae7482ac..e353b0e32 100644 --- a/libhb/muxavformat.c +++ b/libhb/muxavformat.c @@ -673,7 +673,7 @@ static int avformatInit( hb_mux_object_t * m ) track->st->codecpar->channel_layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); } - char *name; + const char *name; if (audio->config.out.name == NULL) { switch (track->st->codecpar->channels) -- cgit v1.2.3