summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/afdko/0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch
blob: eb4a03e68647eb1faaf8855f05dbdb32c68105d1 (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
From 91833ab6c1a769f82f30dbf126362d079905bfc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=A9clairevoyant?=
 <848000+eclairevoyant@users.noreply.github.com>
Date: Fri, 26 Jun 2026 21:28:41 -0400
Subject: [PATCH] addfeatures/hmtx: avoid unsigned integer underflow

---
 c/addfeatures/hotconv/hmtx.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/c/addfeatures/hotconv/hmtx.cpp b/c/addfeatures/hotconv/hmtx.cpp
index 9336c986..2d8ca98e 100644
--- a/c/addfeatures/hotconv/hmtx.cpp
+++ b/c/addfeatures/hotconv/hmtx.cpp
@@ -52,12 +52,12 @@ int hmtxFill(hotCtx g) {
     /* Optimize metrics */
     FWord width = hmtx.advanceWidth.back();
     size_t i;
-    for (i = hmtx.advanceWidth.size() - 2; i >= 0; i--) {
-        if (hmtx.advanceWidth[i] != width)
+    for (i = hmtx.advanceWidth.size(); i >= 2; i--) {
+        if (hmtx.advanceWidth[i-2] != width)
             break;
     }
-    if (i + 2 != hmtx.advanceWidth.size())
-        hmtx.advanceWidth.resize(i+2);
+    if (i != hmtx.advanceWidth.size())
+        hmtx.advanceWidth.resize(i);
 
     return hmtx.Fill();
 }
-- 
2.54.0