hls: Don't persist http options that haven't been set

Message ID 1449491743-80375-1-git-send-email-martin@martin.st
State New
Headers show

Commit Message

Martin Storsjö Dec. 7, 2015, 12:35 p.m.
av_opt_get does return the empty string for options that aren't set.

This avoids warnings about "No trailing CRLF found in HTTP header."
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luca Barbato Dec. 7, 2015, 3:30 p.m. | #1
On 07/12/15 13:35, Martin Storsjö wrote:
> av_opt_get does return the empty string for options that aren't set.
> 
> This avoids warnings about "No trailing CRLF found in HTTP header."
> ---
>  libavformat/hls.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index dc3ab87..db4da31 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -497,7 +497,7 @@ static int save_avio_options(AVFormatContext *s)
>      int ret = 0;
>  
>      while (*opt) {
> -        if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
> +        if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0 && *buf) {
>              ret = av_dict_set(&c->avio_opts, *opt, buf,
>                                AV_DICT_DONT_STRDUP_VAL);
>              if (ret < 0)
> 

Ok.
Martin Storsjö Dec. 8, 2015, 7:41 a.m. | #2
On Mon, 7 Dec 2015, Martin Storsjö wrote:

> av_opt_get does return the empty string for options that aren't set.
>
> This avoids warnings about "No trailing CRLF found in HTTP header."
> ---
> libavformat/hls.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index dc3ab87..db4da31 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -497,7 +497,7 @@ static int save_avio_options(AVFormatContext *s)
>     int ret = 0;
>
>     while (*opt) {
> -        if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
> +        if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0 && *buf) {
>             ret = av_dict_set(&c->avio_opts, *opt, buf,
>                               AV_DICT_DONT_STRDUP_VAL);
>             if (ret < 0)
> -- 
> 2.4.9 (Apple Git-60)

Actually, this would leak the empty strings returned.

I'll send a better way of solving this issue.

// Martin

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index dc3ab87..db4da31 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -497,7 +497,7 @@  static int save_avio_options(AVFormatContext *s)
     int ret = 0;
 
     while (*opt) {
-        if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) {
+        if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0 && *buf) {
             ret = av_dict_set(&c->avio_opts, *opt, buf,
                               AV_DICT_DONT_STRDUP_VAL);
             if (ret < 0)