fix(gamefont): Ceil font glyph buffer size to the actual glyph size to prevent a buffer write overflow - #3268
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Summary by QodoPrevent large glyphs from overflowing font buffers
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1. Oversized interface text disappears
|
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameClient/GUI/GameFont.cpp | Clamps positive font requests to 512 points at the common font-creation boundary. |
| Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp | Allocates glyph buffers according to required capacity, checks their recorded lengths, and releases their pixel arrays correctly. |
| Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h | Replaces the fixed pixel array with a value descriptor containing allocated length and pixel pointer. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Request[Font request] --> Clamp[Clamp point size to 512]
Clamp --> Glyph[Rasterize glyph]
Glyph --> Size[Compute width × height]
Size --> Capacity{Current buffer has capacity?}
Capacity -->|Yes| Store[Store glyph pixels]
Capacity -->|No| Allocate[Allocate max of default capacity and glyph size]
Allocate --> Store
Store --> Destroy[Font destruction]
Destroy --> Free[Delete each pixel array]
Reviews (6): Last reviewed commit: "refactor(gamefont): Store glyph buffer d..." | Re-trigger Greptile
dbebfc4 to
33b6309
Compare
|
Can't we use At what font size did it overflow the original buffer? Was this leading to crashes? |
Theoretically somewhere around 130 to 150 point, can also be triggered by something like a custom map with
Each glyph caches a raw pointer into its slab |
|
Do this effect PR #3231 ? |
eae556c to
cb3ed94
Compare
1ce2f06 to
099cb78
Compare
The glyph buffer was a fixed
uint16[32768].Store_GDI_Charwriteswidth * heightpixels with no bound check, so a big glyph writes past the end.A
pointSize > 100cap used to hide this, but it was removed in #3051 so 4K UI scalingcan use bigger fonts. A scaled font can now hit the overflow.
FontCharsBufferallocates its pixels and grows to fit the glyph.getFontclamps requests to 512 instead of rejecting them, so an oversizedrequest still returns a usable font rather than
nullptr(callers likeW3DDisplayString::setFontignore null and would show no text).A font size of about 460 is the most any real screen needs (a 48pt heading blown up 9.6x on an 8K display) so I think 512 is a safe value for now.