aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki2@gmail.com>2014-11-20 00:28:03 +0100
committerLukasz Marek <lukasz.m.luki2@gmail.com>2014-11-26 23:32:33 +0100
commit3cb0bec6870cf0bb7879f7bfd4119ef39a02a464 (patch)
treea70ac3415cdf32de8cd06f9964581ce84a7cc5d6
parentec6e035b8b1fcd7a1838ac12c887389a44af4d98 (diff)
downloadffmpeg-3cb0bec6870cf0bb7879f7bfd4119ef39a02a464.tar.gz
ffserver: dont leak child arguments
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
-rw-r--r--ffserver.c2
-rw-r--r--ffserver_config.c20
-rw-r--r--ffserver_config.h2
3 files changed, 21 insertions, 3 deletions
diff --git a/ffserver.c b/ffserver.c
index 3702fd638a..012056dd48 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -3663,7 +3663,7 @@ static void handle_child_exit(int sig)
if (uptime < 30)
/* Turn off any more restarts */
- feed->child_argv = 0;
+ ffserver_free_child_args(&feed->child_argv);
}
}
}
diff --git a/ffserver_config.c b/ffserver_config.c
index f34dc5e5b2..5f01e43f97 100644
--- a/ffserver_config.c
+++ b/ffserver_config.c
@@ -31,6 +31,8 @@
#include "cmdutils.h"
#include "ffserver_config.h"
+#define MAX_CHILD_ARGS 64
+
static int ffserver_save_avoption(const char *opt, const char *arg, int type,
FFServerConfig *config);
static void vreport_config_error(const char *filename, int line_num, int log_level,
@@ -691,10 +693,10 @@ static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, c
if (!av_strcasecmp(cmd, "Launch")) {
int i;
- feed->child_argv = av_mallocz(64 * sizeof(char *));
+ feed->child_argv = av_mallocz_array(MAX_CHILD_ARGS, sizeof(char *));
if (!feed->child_argv)
return AVERROR(ENOMEM);
- for (i = 0; i < 62; i++) {
+ for (i = 0; i < MAX_CHILD_ARGS - 2; i++) {
ffserver_get_arg(arg, sizeof(arg), p);
if (!arg[0])
break;
@@ -1255,3 +1257,17 @@ int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config)
#undef ERROR
#undef WARNING
+
+void ffserver_free_child_args(void *argsp)
+{
+ int i;
+ char **args;
+ if (!argsp)
+ return;
+ args = *(char ***)argsp;
+ if (!args)
+ return;
+ for (i = 0; i < MAX_CHILD_ARGS; i++)
+ av_free(args[i]);
+ av_freep(argsp);
+}
diff --git a/ffserver_config.h b/ffserver_config.h
index 4e1e0e09fc..bdeb3c990a 100644
--- a/ffserver_config.h
+++ b/ffserver_config.h
@@ -128,4 +128,6 @@ void ffserver_parse_acl_row(FFServerStream *stream, FFServerStream* feed,
int ffserver_parse_ffconfig(const char *filename, FFServerConfig *config);
+void ffserver_free_child_args(void *argsp);
+
#endif /* FFSERVER_CONFIG_H */