This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 2deca0ec19a1d36afc12190436d718b4d3a2a596
Author:     Niklas Haas <[email protected]>
AuthorDate: Wed Mar 25 11:14:06 2026 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Fri Apr 10 15:12:18 2026 +0200

    swscale: clean up allocated frames on error
    
    Matches the semantics of sws_frame_begin(), which also cleans up any
    allocated buffers on error.
    
    This is an issue introduced by the commit that allowed ff_sws_graph_run()
    to fail in the first place.
    
    Fixes: 563cc8216bd9253d2563641341f4af611aaf9554
---
 libswscale/swscale.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 481cab091c..d5c91e541c 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1366,7 +1366,7 @@ static int frame_ref(AVFrame *dst, const AVFrame *src)
 
 int sws_scale_frame(SwsContext *sws, AVFrame *dst, const AVFrame *src)
 {
-    int ret;
+    int ret, allocated = 0;
     SwsInternal *c = sws_internal(sws);
     if (!src || !dst)
         return AVERROR(EINVAL);
@@ -1411,12 +1411,16 @@ int sws_scale_frame(SwsContext *sws, AVFrame *dst, 
const AVFrame *src)
     ret = frame_alloc_buffers(sws, dst);
     if (ret < 0)
         return ret;
+    allocated = 1;
 
 process_frame:
     for (int field = 0; field < (bot ? 2 : 1); field++) {
         ret = ff_sws_graph_run(c->graph[field], dst, src);
-        if (ret < 0)
+        if (ret < 0) {
+            if (allocated)
+                av_frame_unref(dst);
             return ret;
+        }
     }
 
     return 0;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to