diff options
| author | mzxrules <mzxrules@gmail.com> | 2026-02-17 04:31:54 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-17 10:31:54 +0100 |
| commit | 95495d221fb8c34b9903c7fa03870c2834bf5b2c (patch) | |
| tree | 627e688ba1071928dca4d008cba141e55372c98b /src/code | |
| parent | 834b443bbb4dac9eda4c37272e07bf007dcc44c0 (diff) | |
Document SysCfb_GetFbPtr bug (#2586)
* Document SysCfb_GetFbPtr bug
* cleaner comment
* fixes
* change wording again
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/graph.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/code/graph.c b/src/code/graph.c index 56fc7af60..c6b5f3cb6 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -141,6 +141,13 @@ void Graph_InitTHGA(GraphicsContext* gfxCtx) { gfxCtx->overlayBuffer = pool->overlayBuffer; gfxCtx->workBuffer = pool->workBuffer; + //! @bug fbIdx is a signed integer that can overflow into the negatives. When compiled with a C99+ compiler or IDO, + //! the remainder operator will yield -1 for odd negative values of fbIdx. + //! This causes SysCfb_GetFbPtr to read beyond the bounds of an array when retrieving the framebuffer pointer, which + //! will likely crash the game. + //! + //! This isn't an issue in practice. In the worst case scenario with the game operating at a consistent 60 FPS, + //! it would take approximately 414.25 days of continuous operation for fbIdx to overflow. gfxCtx->curFrameBuffer = SysCfb_GetFbPtr(gfxCtx->fbIdx % 2); gfxCtx->unk_014 = 0; } |
