From 6a178dee963f4a05dcfdd3eb76f90e9935b074b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Sun, 5 Feb 2017 19:51:31 +0900 Subject: [PATCH] Fix leaking memory when --cqmfile given many times Any previously allocated CQM file name was not freed when allocating memory for the new file name. --- src/cfg.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index d8e8ef06..dcca593c 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -658,8 +658,15 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) cfg->vui.chroma_loc = atoi(value); else if OPT("aud") cfg->aud_enable = atobool(value); - else if OPT("cqmfile") - cfg->cqmfile = strdup(value); + else if OPT("cqmfile") { + char* cqmfile = strdup(value); + if (!cqmfile) { + fprintf(stderr, "Failed to allocate memory for CQM file name.\n"); + return 0; + } + FREE_POINTER(cfg->cqmfile); + cfg->cqmfile = cqmfile; + } else if OPT("tiles-width-split") { int retval = parse_tiles_specification(value, &cfg->tiles_width_count, &cfg->tiles_width_split);