Skip to content

Fix integer overflow in FpsCounter initialization#2

Open
teleyos wants to merge 1 commit intomuhammad-fiaz:mainfrom
teleyos:fix/fps-counter-integer-overflow
Open

Fix integer overflow in FpsCounter initialization#2
teleyos wants to merge 1 commit intomuhammad-fiaz:mainfrom
teleyos:fix/fps-counter-integer-overflow

Conversation

@teleyos
Copy link

@teleyos teleyos commented Jan 21, 2026

Summary

  • Fix FpsCounter default initialization to prevent integer overflow

Problem

The fps_counter field in App was default-initialized with .{}:

fps_counter: animation.FpsCounter = .{},

This leaves frame_times: [60]u32 = undefined as garbage values. When update() runs, it subtracts frame times from the current timestamp, which causes an integer underflow if the garbage values exceed the current time.

Solution

Use animation.FpsCounter.init() to properly zero-initialize the frame times array:

fps_counter: animation.FpsCounter = animation.FpsCounter.init(),

Test plan

  • Build and run a basic tui.zig app - no more integer overflow crash

🤖 Generated with Claude Code

The `fps_counter` field was default-initialized with `.{}`, which left
`frame_times: [60]u32 = undefined` as garbage values. When `update()`
runs, it subtracts frame times from the current timestamp, causing
integer underflow if the garbage values exceed the current time.

This fix uses `animation.FpsCounter.init()` to properly zero-initialize
the frame times array.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments