File: nametabletest-NameRecord-bounds.diff

package info (click to toggle)
graphite2 1.3.14-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,592 kB
  • sloc: cpp: 14,738; cs: 1,998; python: 1,737; ansic: 1,673; perl: 184; xml: 123; sh: 97; makefile: 53
file content (29 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download
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
Origin: https://github.com/silnrsi/graphite/pull/106
From: Bastian Germann <bage@debian.org>
Date: Sat, 28 Mar 2026 12:24:45 +0100
Subject: tests: fix nametabletest NameRecord conversion bounds

The synthetic name-table builder copied one too many NameRecord entries in
toBigEndian().

FontNames already contains name_record[0], while m_records stores only the
remaining count-1 records. The loop used count, so for NameTestB (count=8,
m_records[7]) it wrote past m_records and corrupted adjacent fields
(m_langTagCount/lang tags).

That memory corruption breaks format 1 language-tag lookup and causes
fallback behavior.

Fixes: #96
---
--- a/tests/nametabletest/nametabletest.cpp
+++ b/tests/nametabletest/nametabletest.cpp
@@ -137,7 +137,7 @@ template <class T> T * toBigEndian(T & table)
     bigEndian->m_nameHeader.count = be::swap<uint16>(table.m_nameHeader.count);
     bigEndian->m_nameHeader.string_offset = be::swap<uint16>(table.m_nameHeader.string_offset);
 
-    for (uint16 i = 0; i < table.m_nameHeader.count; i++)
+    for (uint16 i = 0; i + 1 < table.m_nameHeader.count; i++)
     {
         bigEndian->m_records[i].platform_id = be::swap<uint16>(table.m_records[i].platform_id);
         bigEndian->m_records[i].platform_specific_id = be::swap<uint16>(table.m_records[i].platform_specific_id);