[FFmpeg-devel] [PATCH] opt: re-enable memleak fix for duplicated options.

Clément Bœsch ubitux at gmail.com
Thu Nov 15 16:17:05 CET 2012


From: Clément Bœsch <clement.boesch at smartjog.com>

The memleak fix in a1bcc76e was causing problems when the original
string wasn't NULL or av_malloc'ed, thus was disabled. It seems the only
OPT_STRING occurence where it needs to be fixed is in ffserver. This
commit fixes that specific problem and so re-enable the original code.
---
 cmdutils.c |    2 +-
 ffserver.c |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 1c392d7..83d9e44 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -306,7 +306,7 @@ int parse_option(void *optctx, const char *opt, const char *arg,
     if (po->flags & OPT_STRING) {
         char *str;
         str = av_strdup(arg);
-//         av_freep(dst);
+        av_freep(dst);
         *(char **)dst = str;
     } else if (po->flags & OPT_BOOL) {
         *(int *)dst = bool_val;
diff --git a/ffserver.c b/ffserver.c
index 1f27237..345e7e8 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -308,7 +308,7 @@ static int rtp_new_av_stream(HTTPContext *c,
 static const char *my_program_name;
 static const char *my_program_dir;
 
-static const char *config_filename = "/etc/ffserver.conf";
+static const char *config_filename;
 
 static int ffserver_debug;
 static int ffserver_daemon;
@@ -4730,6 +4730,9 @@ int main(int argc, char **argv)
 
     parse_options(NULL, argc, argv, options, NULL);
 
+    if (!config_filename)
+        config_filename = av_strdup("/etc/ffserver.conf");
+
     unsetenv("http_proxy");             /* Kill the http_proxy */
 
     av_lfg_init(&random_state, av_get_random_seed());
@@ -4742,6 +4745,7 @@ int main(int argc, char **argv)
         fprintf(stderr, "Incorrect config file - exiting.\n");
         exit(1);
     }
+    av_freep(&config_filename);
 
     /* open log file if needed */
     if (logfilename[0] != '\0') {
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list