Skip to content

Add overflow detection to tensor size calculations#3533

Open
TristanInSec wants to merge 1 commit intotensorflow:mainfrom
TristanInSec:fix-tensor-size-overflow
Open

Add overflow detection to tensor size calculations#3533
TristanInSec wants to merge 1 commit intotensorflow:mainfrom
TristanInSec:fix-tensor-size-overflow

Conversation

@TristanInSec
Copy link
Copy Markdown

@TristanInSec TristanInSec commented Apr 17, 2026

Use size_t instead of int for element count accumulation in BytesRequiredForTensor and TfLiteEvalTensorByteLength. Validate each dimension is positive and check for multiplication overflow before computing the final byte count.

This brings the size calculation in line with safe arithmetic practices used elsewhere in the codebase.

BUG=b/general

Use size_t instead of int for element count accumulation in
BytesRequiredForTensor and TfLiteEvalTensorByteLength. Validate
each dimension is positive and check for multiplication overflow
before computing the final byte count.
@TristanInSec TristanInSec requested a review from a team as a code owner April 17, 2026 19:31
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.

2 participants