From f0677291d12a28e06d11aeaad781e843010dac28 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 28 Feb 2020 11:52:38 -0300 Subject: [PATCH] launch: Fix memory management issue with the rendering format --- tools/ges-launcher.c | 17 +++++++++++------ tools/utils.c | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/ges-launcher.c b/tools/ges-launcher.c index f13cd1d9e7..5722740b9b 100644 --- a/tools/ges-launcher.c +++ b/tools/ges-launcher.c @@ -477,8 +477,6 @@ _set_rendering_details (GESLauncher * self) /* Setup profile/encoding if needed */ if (opts->outputuri) { GstEncodingProfile *prof = NULL; - gchar *format = NULL; - if (!opts->format) { GESProject *proj = GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (self-> @@ -496,18 +494,25 @@ _set_rendering_details (GESLauncher * self) } if (!prof) { - if (opts->format == NULL) + if (opts->format == NULL) { opts->format = get_file_extension (opts->outputuri); - prof = parse_encoding_profile (opts->format); + prof = parse_encoding_profile (opts->format); + } else { + prof = parse_encoding_profile (opts->format); + if (!prof) + g_error ("Invalid format specified: %s", opts->format); + } + if (!prof) { warn ("No format specified and couldn't find one from output file extension, " "falling back to theora+vorbis in ogg."); - format = opts->format = + g_free (opts->format); + + opts->format = g_strdup ("application/ogg:video/x-theora:audio/x-vorbis"); prof = parse_encoding_profile (opts->format); } - g_free (format); if (!prof) { printerr ("Could not find any encoding format for %s\n", opts->format); return FALSE; diff --git a/tools/utils.c b/tools/utils.c index 614effa9ca..f7049f0b78 100644 --- a/tools/utils.c +++ b/tools/utils.c @@ -232,7 +232,7 @@ get_file_extension (gchar * uri) if (find <= 0) return NULL; - return &uri[find + 1]; + return g_strdup (&uri[find + 1]); } static const gchar *