diff mbox series

[FFmpeg-devel,v1] avformat/mxfdec: use av_asprintf()

Message ID 20200322150321.23023-1-lance.lmwang@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,v1] avformat/mxfdec: use av_asprintf()
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Limin Wang March 22, 2020, 3:03 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/mxfdec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Tomas Härdin March 23, 2020, 7:29 p.m. UTC | #1
sön 2020-03-22 klockan 23:03 +0800 skrev lance.lmwang@gmail.com:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/mxfdec.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 9113e2a09c..3374f36a88 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -2017,7 +2017,7 @@ static MXFStructuralComponent*
> mxf_resolve_sourceclip(MXFContext *mxf, UID *stro
>  static int mxf_parse_package_comments(MXFContext *mxf, AVDictionary
> **pm, MXFPackage *package)
>  {
>      MXFTaggedValue *tag;
> -    int size, i;
> +    int i;
>      char *key = NULL;
>  
>      for (i = 0; i < package->comment_count; i++) {
> @@ -2025,12 +2025,10 @@ static int
> mxf_parse_package_comments(MXFContext *mxf, AVDictionary **pm, MXFPac
>          if (!tag || !tag->name || !tag->value)
>              continue;
>  
> -        size = strlen(tag->name) + 8 + 1;
> -        key = av_mallocz(size);
> +        key = av_asprintf("comment_%s", tag->name);
>          if (!key)
>              return AVERROR(ENOMEM);
>  
> -        snprintf(key, size, "comment_%s", tag->name);
>          av_dict_set(pm, key, tag->value, AV_DICT_DONT_STRDUP_KEY);
>      }
>      return 0;

Looks OK

/Tomas
Michael Niedermayer March 23, 2020, 9:52 p.m. UTC | #2
On Mon, Mar 23, 2020 at 08:29:32PM +0100, Tomas Härdin wrote:
> sön 2020-03-22 klockan 23:03 +0800 skrev lance.lmwang@gmail.com:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavformat/mxfdec.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> > index 9113e2a09c..3374f36a88 100644
> > --- a/libavformat/mxfdec.c
> > +++ b/libavformat/mxfdec.c
> > @@ -2017,7 +2017,7 @@ static MXFStructuralComponent*
> > mxf_resolve_sourceclip(MXFContext *mxf, UID *stro
> >  static int mxf_parse_package_comments(MXFContext *mxf, AVDictionary
> > **pm, MXFPackage *package)
> >  {
> >      MXFTaggedValue *tag;
> > -    int size, i;
> > +    int i;
> >      char *key = NULL;
> >  
> >      for (i = 0; i < package->comment_count; i++) {
> > @@ -2025,12 +2025,10 @@ static int
> > mxf_parse_package_comments(MXFContext *mxf, AVDictionary **pm, MXFPac
> >          if (!tag || !tag->name || !tag->value)
> >              continue;
> >  
> > -        size = strlen(tag->name) + 8 + 1;
> > -        key = av_mallocz(size);
> > +        key = av_asprintf("comment_%s", tag->name);
> >          if (!key)
> >              return AVERROR(ENOMEM);
> >  
> > -        snprintf(key, size, "comment_%s", tag->name);
> >          av_dict_set(pm, key, tag->value, AV_DICT_DONT_STRDUP_KEY);
> >      }
> >      return 0;
> 
> Looks OK

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 9113e2a09c..3374f36a88 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2017,7 +2017,7 @@  static MXFStructuralComponent* mxf_resolve_sourceclip(MXFContext *mxf, UID *stro
 static int mxf_parse_package_comments(MXFContext *mxf, AVDictionary **pm, MXFPackage *package)
 {
     MXFTaggedValue *tag;
-    int size, i;
+    int i;
     char *key = NULL;
 
     for (i = 0; i < package->comment_count; i++) {
@@ -2025,12 +2025,10 @@  static int mxf_parse_package_comments(MXFContext *mxf, AVDictionary **pm, MXFPac
         if (!tag || !tag->name || !tag->value)
             continue;
 
-        size = strlen(tag->name) + 8 + 1;
-        key = av_mallocz(size);
+        key = av_asprintf("comment_%s", tag->name);
         if (!key)
             return AVERROR(ENOMEM);
 
-        snprintf(key, size, "comment_%s", tag->name);
         av_dict_set(pm, key, tag->value, AV_DICT_DONT_STRDUP_KEY);
     }
     return 0;