Commit db85d11d authored by Alexander Strasser's avatar Alexander Strasser

libavformat/ftp: Do not leak memory in routine ftp_features

Setting the pointer to NULL inside both ftp_send_command
and ftp_features is redundant. Generally always setting to
NULL in ftp_send_command seems safer, but throughout the file
that parameter was always passed initialized. So I do it here
too for consistency.

Should fix CID1231988 (RESOURCE_LEAK)
OKed-by: 's avatarLukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: 's avatarAlexander Strasser <eclipse7@gmx.net>
parent f75baa6c
...@@ -183,6 +183,9 @@ static int ftp_send_command(FTPContext *s, const char *command, ...@@ -183,6 +183,9 @@ static int ftp_send_command(FTPContext *s, const char *command,
{ {
int err; int err;
if (response)
*response = NULL;
if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0) if ((err = ffurl_write(s->conn_control, command, strlen(command))) < 0)
return err; return err;
if (!err) if (!err)
...@@ -444,12 +447,14 @@ static int ftp_features(FTPContext *s) ...@@ -444,12 +447,14 @@ static int ftp_features(FTPContext *s)
static const char *enable_utf8_command = "OPTS UTF8 ON\r\n"; static const char *enable_utf8_command = "OPTS UTF8 ON\r\n";
static const int feat_codes[] = {211, 0}; static const int feat_codes[] = {211, 0};
static const int opts_codes[] = {200, 451}; static const int opts_codes[] = {200, 451};
char *feat; char *feat = NULL;
if (ftp_send_command(s, feat_command, feat_codes, &feat) == 211) { if (ftp_send_command(s, feat_command, feat_codes, &feat) == 211) {
if (av_stristr(feat, "UTF8")) if (av_stristr(feat, "UTF8"))
ftp_send_command(s, enable_utf8_command, opts_codes, NULL); ftp_send_command(s, enable_utf8_command, opts_codes, NULL);
} }
av_freep(&feat);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment