diff options
author | John Stebbins <[email protected]> | 2019-08-30 15:38:33 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2019-08-30 15:40:05 -0700 |
commit | dad30fe9809d3c976227953af73ac4016308e998 (patch) | |
tree | de0b47ff6200922f7bb20765248c42de93828ca4 | |
parent | 6101f387c8a77de9e0a464ddd03fae96a3dc3c11 (diff) |
hb_json: fix double free
json_unpack returns references to embedded strings. We need to strdup
these when filling job structure.
-rw-r--r-- | libhb/hb_json.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libhb/hb_json.c b/libhb/hb_json.c index 9f5286d7f..65b553c92 100644 --- a/libhb/hb_json.c +++ b/libhb/hb_json.c @@ -1548,7 +1548,10 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) audio.out.dither_method = hb_value_get_int(dither); } } - audio.out.name = name; + if (name != NULL) + { + audio.out.name = strdup(name); + } if (audio.in.track >= 0) { audio.out.track = ii; @@ -1615,7 +1618,10 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) if (subtitle != NULL) { sub_config = subtitle->config; - sub_config.name = name; + if (name != NULL) + { + sub_config.name = strdup(name); + } result = json_unpack_ex(subtitle_dict, &error, 0, "{s?b, s?b, s?b, s?I}", "Default", unpack_b(&sub_config.default_track), @@ -1635,7 +1641,7 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) } else if (importfile != NULL) { - sub_config.src_filename = importfile; + sub_config.src_filename = strdup(importfile); const char * lang = "und"; const char * srtcodeset = "UTF-8"; @@ -1663,7 +1669,10 @@ hb_job_t* hb_dict_to_job( hb_handle_t * h, hb_dict_t *dict ) hb_job_close(&job); return NULL; } - sub_config.name = name; + if (name != NULL) + { + sub_config.name = strdup(name); + } sub_config.offset = offset; sub_config.dest = burn ? RENDERSUB : PASSTHRUSUB; strncpy(sub_config.src_codeset, srtcodeset, 39); |