mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
[glyf] Guard phantom-shift subarray against OOM underflow
In phantom_only mode the horizontal shift walks all_points.sub_array (all_points.length - PHANTOM_COUNT). If the preceding extend (phantoms) failed under memory pressure, all_points can be shorter than PHANTOM_COUNT, so the subtraction wraps and the code forms an out-of-range pointer (UB flagged by UBSan under the failing-malloc fuzzers) even though sub_array clamps the count to 0 and the in-error result is discarded. Fall back to offset 0 when the phantoms are not present. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
820032a852
commit
7b7e4ef3d1
1 file changed
+7
-1
@@ -588,8 +588,14 @@ struct Glyph
|
||||
* Shift points horizontally by the updated left side bearing
|
||||
*/
|
||||
if (shift)
|
||||
for (auto &point : all_points.as_array ().sub_array (phantom_only ? all_points.length - PHANTOM_COUNT : 0))
|
||||
{
|
||||
/* Guard the subtraction: a failed phantom extend() under OOM can
|
||||
* leave all_points shorter than PHANTOM_COUNT. */
|
||||
unsigned start = phantom_only && all_points.length >= PHANTOM_COUNT
|
||||
? all_points.length - PHANTOM_COUNT : 0;
|
||||
for (auto &point : all_points.as_array ().sub_array (start))
|
||||
point.x -= shift;
|
||||
}
|
||||
}
|
||||
|
||||
return !all_points.in_error ();
|
||||
|
||||
Reference in new issue
Block a user