[PR #2309] indirect_draw_stats: guard null FILE* in report and out-of-range Event in note/skip #2311

Open
opened 2026-11-26 21:20:46 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2309
Author: @narekshaghoyandev
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: ubiq-indirect-draw-stats-guards


📝 Commits (1)

  • 25aed3f indirect_draw_stats: guard null FILE* in report and out-of-range Event in note/skip

📊 Changes

2 files changed (+58 additions, -2 deletions)

View changed files

📝 runtime/src/indirect_draw_stats.h (+5 -2)
➕ runtime/test/indirect_draw_stats_test.cpp (+53 -0)

📄 Description

Fixes null-pointer and out-of-bounds bugs in runtime/src/indirect_draw_stats.h:

  • Guard Counts::report(std::FILE* out) against out == nullptr before calling std::fprintf(out, ...).
  • Bounds-check static_cast<unsigned>(event) < 4u in note(Event) and skip(Event, Reason) so an out-of-range Event cannot index past Counts::values[4] or record a stray reason skip.
  • Added standalone unit test runtime/test/indirect_draw_stats_test.cpp.

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/indirect_draw_stats_test.cpp passed
  • g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/indirect_draw_stats_test.cpp passed
  • Negative control: new test failed with UBSan null-argument + ASan SEGV against unmodified ubiq/main
  • python3 -I scripts/check_no_game_data.py runtime/src/indirect_draw_stats.h runtime/test/indirect_draw_stats_test.cpp clean

Claimed in the coordination issue as: RT-INDIRECT-DRAW-STATS-BOUNDS-AND-NULL (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193658432)
AI-assisted: yes (Gemini)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2309 **Author:** [@narekshaghoyandev](https://github.com/narekshaghoyandev) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ubiq-indirect-draw-stats-guards` --- ### 📝 Commits (1) - [`25aed3f`](https://github.com/ubiquitarianism/leonida/commit/25aed3fcb1f6f3c68a1123a587e08d3bfe712bf1) indirect_draw_stats: guard null FILE* in report and out-of-range Event in note/skip ### 📊 Changes **2 files changed** (+58 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/indirect_draw_stats.h` (+5 -2) ➕ `runtime/test/indirect_draw_stats_test.cpp` (+53 -0) </details> ### 📄 Description Fixes null-pointer and out-of-bounds bugs in `runtime/src/indirect_draw_stats.h`: - Guard `Counts::report(std::FILE* out)` against `out == nullptr` before calling `std::fprintf(out, ...)`. - Bounds-check `static_cast<unsigned>(event) < 4u` in `note(Event)` and `skip(Event, Reason)` so an out-of-range `Event` cannot index past `Counts::values[4]` or record a stray reason skip. - Added standalone unit test `runtime/test/indirect_draw_stats_test.cpp`. ### Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/indirect_draw_stats_test.cpp` passed - `g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/indirect_draw_stats_test.cpp` passed - Negative control: new test failed with UBSan null-argument + ASan SEGV against unmodified `ubiq/main` - `python3 -I scripts/check_no_game_data.py runtime/src/indirect_draw_stats.h runtime/test/indirect_draw_stats_test.cpp` clean Claimed in the coordination issue as: RT-INDIRECT-DRAW-STATS-BOUNDS-AND-NULL (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193658432) AI-assisted: yes (Gemini) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2311
No description provided.