File 029-CVE-2022-22816.patch of Package python-Pillow

From c48271ab354db49cdbd740bc45e13be4f0f7993c Mon Sep 17 00:00:00 2001
From: Andrew Murray <radarhere@users.noreply.github.com>
Date: Mon, 6 Dec 2021 22:25:14 +1100
Subject: [PATCH] Handle case where path count is zero

---
 Tests/test_imagepath.py |  1 +
 src/path.c              | 33 +++++++++++++++++++--------------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/path.c b/src/path.c
index 64c767cb88..dea274ee33 100644
--- a/src/path.c
+++ b/src/path.c
@@ -326,18 +326,27 @@ path_getbbox(PyPathObject* self, PyObject* args)

     xy = self->xy;

-    x0 = x1 = xy[0];
-    y0 = y1 = xy[1];
-
-    for (i = 1; i < self->count; i++) {
-        if (xy[i+i] < x0)
-            x0 = xy[i+i];
-        if (xy[i+i] > x1)
-            x1 = xy[i+i];
-        if (xy[i+i+1] < y0)
-            y0 = xy[i+i+1];
-        if (xy[i+i+1] > y1)
-            y1 = xy[i+i+1];
+    if (self->count == 0) {
+        x0 = x1 = 0;
+        y0 = y1 = 0;
+    } else {
+        x0 = x1 = xy[0];
+        y0 = y1 = xy[1];
+
+        for (i = 1; i < self->count; i++) {
+            if (xy[i + i] < x0) {
+                x0 = xy[i + i];
+            }
+            if (xy[i + i] > x1) {
+                x1 = xy[i + i];
+            }
+            if (xy[i + i + 1] < y0) {
+                y0 = xy[i + i + 1];
+            }
+            if (xy[i + i + 1] > y1) {
+                y1 = xy[i + i + 1];
+            }
+        }
     }

     return Py_BuildValue("dddd", x0, y0, x1, y1);
openSUSE Build Service is sponsored by