summaryrefslogtreecommitdiff
path: root/media-libs/mlt/files/mlt-7.20.0-qtblend-crash.patch
blob: aad8f0e9e45cdf269d92ad8eddc15b43fe794b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 09f55bf3d1fdcac06c5d297bb27cb4f3e7f85021 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Mardelle <jb@kdenlive.org>
Date: Thu, 5 Oct 2023 08:45:16 +0200
Subject: [PATCH] Ensure qtblend doesn't request an image of 0 width or height
 (crashes many filters)

---
 src/modules/qt/filter_qtblend.cpp     | 6 +++---
 src/modules/qt/transition_qtblend.cpp | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/modules/qt/filter_qtblend.cpp b/src/modules/qt/filter_qtblend.cpp
index d54f7ccad..32d752d60 100644
--- a/src/modules/qt/filter_qtblend.cpp
+++ b/src/modules/qt/filter_qtblend.cpp
@@ -103,10 +103,10 @@ static int filter_get_image(mlt_frame frame,
                    || rect.h != *height;
 
         if (mlt_properties_get_int(properties, "distort") == 0) {
-            b_height = qMin((int) rect.h, b_height);
-            b_width = b_height * b_dar / b_ar / consumer_ar;
+            b_height = qMax(1, qMin((int) rect.h, b_height));
+            b_width = qMax(1, int(b_height * b_dar / b_ar / consumer_ar));
         } else {
-            b_width *= b_ar / consumer_ar;
+            b_width = qMax(1, int(b_width * b_ar / consumer_ar));
         }
         if (!hasAlpha && (b_width < *width || b_height < *height)) {
             hasAlpha = true;
diff --git a/src/modules/qt/transition_qtblend.cpp b/src/modules/qt/transition_qtblend.cpp
index 9dbc795aa..0b41b3ff8 100644
--- a/src/modules/qt/transition_qtblend.cpp
+++ b/src/modules/qt/transition_qtblend.cpp
@@ -121,6 +121,9 @@ static int get_image(mlt_frame a_frame,
             // we will process operations on top frame, so also process b_frame
             forceAlpha = true;
         }
+        // Ensure we don't request an image with a 0 width or height
+        b_width = qMax(1, b_width);
+        b_height = qMax(1, b_height);
     } else {
         b_height = *height;
         b_width = *width;