Potential fix for code scanning alert no. 1: Multiplication result converted to larger type - #802
Merged
Merged
Conversation
PabloCarmona
marked this pull request as ready for review
September 30, 2026 08:01
…nverted to larger type Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com>
…nverted to larger type (#797) * Potential fix for code scanning alert no. 5: Multiplication result converted to larger type Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com> * fix(rpucuda): cast size_t for refresh vector resizing Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com> * fix(periphery): simplify input_range assignment logic Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com> --------- Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com>
PabloCarmona
force-pushed
the
alert-autofix-1
branch
from
September 30, 2026 11:16
b02d737 to
cd63e84
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/IBM/aihwkit/security/code-scanning/1
To fix this class of issue, ensure multiplication is performed in the larger destination type, not in
int. In practice: cast one (or both) operands tostd::size_t(orstd::vector<T>::size_type) before multiplying, so arithmetic is widened prior to evaluation.Best minimal fix in this file is to change the vector initialization in
RPUSimple<T>::dumpExtraso the product is computed assize_t:src/rpucuda/rpu.cppRPUSimple<T>::dumpExtraV tmp(this->x_size_ * this->d_size_);V tmp(static_cast<typename V::size_type>(this->x_size_) * static_cast<typename V::size_type>(this->d_size_));Using
typename V::size_typekeeps the type aligned with the vector’s expected size type and avoids assumptions about platform widths.Suggested fixes powered by Copilot Autofix. Review carefully before merging.