In case of failure, all the successfully set entries are stored in *pm. We need to manually free the created dictionary to avoid memory leak.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -486,6 +486,7 @@ static av_cold int init(AVFilterContext *fctx) · 485 unmodified lines | |||
| 486 | av_log(ctx, AV_LOG_DEBUG, "Filter_string: %s\n", ctx->filter_string); | 486 | av_log(ctx, AV_LOG_DEBUG, "Filter_string: %s\n", ctx->filter_string); |
| 487 | ret = av_dict_parse_string(&filter_dict, ctx->filter_string, "@", "#", AV_DICT_MULTIKEY); // parse filter_name:all_filter_options | 487 | ret = av_dict_parse_string(&filter_dict, ctx->filter_string, "@", "#", AV_DICT_MULTIKEY); // parse filter_name:all_filter_options |
| 488 | if (ret) { | 488 | if (ret) { |
| 489 | av_dict_free(&filter_dict); | ||
| 489 | av_log(ctx, AV_LOG_ERROR, "Parsing of filters failed.\n"); | 490 | av_log(ctx, AV_LOG_ERROR, "Parsing of filters failed.\n"); |
| 490 | return AVERROR(EIO); | 491 | return AVERROR(EIO); |
| 491 | } | 492 | } |
| @@ -507,6 +508,7 @@ static av_cold int init(AVFilterContext *fctx) · 15 unmodified lines | |||
| 507 | if (strncmp(f->value, "default", 7)) { // not default | 508 | if (strncmp(f->value, "default", 7)) { // not default |
| 508 | ret = av_dict_parse_string(&filter_options, f->value, "=", "@", 0); // parse option_name:option_value | 509 | ret = av_dict_parse_string(&filter_options, f->value, "=", "@", 0); // parse option_name:option_value |
| 509 | if (ret) { | 510 | if (ret) { |
| 511 | av_dict_free(&filter_options); | ||
| 510 | av_log(ctx, AV_LOG_ERROR, "Parsing of filter options for \"%s\" failed.\n", f->key); | 512 | av_log(ctx, AV_LOG_ERROR, "Parsing of filter options for \"%s\" failed.\n", f->key); |
| 511 | return AVERROR(EIO); | 513 | return AVERROR(EIO); |
| 512 | } | 514 | } |