[FFmpeg-cvslog] fftools/cmdutils: only set array size after allocation succeeded

Anton Khirnov git at videolan.org
Thu Nov 9 12:29:56 EET 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Nov  4 07:37:21 2023 +0100| [ed0a50923a8fb36ff6535f5a87bfede41f6fac0e] | committer: Anton Khirnov

fftools/cmdutils: only set array size after allocation succeeded

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed0a50923a8fb36ff6535f5a87bfede41f6fac0e
---

 fftools/cmdutils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 156c13801a..86cd3bddb4 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -665,10 +665,10 @@ static int init_parse_context(OptionParseContext *octx,
 
     memset(octx, 0, sizeof(*octx));
 
-    octx->nb_groups = nb_groups;
-    octx->groups    = av_calloc(octx->nb_groups, sizeof(*octx->groups));
+    octx->groups    = av_calloc(nb_groups, sizeof(*octx->groups));
     if (!octx->groups)
         return AVERROR(ENOMEM);
+    octx->nb_groups = nb_groups;
 
     for (i = 0; i < octx->nb_groups; i++)
         octx->groups[i].group_def = &groups[i];



More information about the ffmpeg-cvslog mailing list