Potential fix for code scanning alert no. 5: Multiplication result converted to larger type - #797
Merged
Merged
Conversation
PabloCarmona
marked this pull request as ready for review
September 29, 2026 08:56
…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>
Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com>
PabloCarmona
force-pushed
the
alert-fix-cast-int
branch
from
September 30, 2026 07:59
4ed8c5e to
844d777
Compare
Signed-off-by: Pablo Carmona Gonzalez <pablocarmonagonzalez@gmail.com>
PabloCarmona
added a commit
that referenced
this pull request
Sep 30, 2026
…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
added a commit
that referenced
this pull request
Sep 30, 2026
…nverted to larger type (#802) * Potential fix for code scanning alert no. 1: 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> * Potential fix for code scanning alert no. 5: Multiplication result converted 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> --------- 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>
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/5
To fix this without changing functionality, ensure the multiplication for indexing is done in
size_t(the vector index type) rather thanint.Specifically in
src/rpucuda/rpu_onesided_device.cppat therefreshWeights()loop, replace:&refresh_vecs_[j_col * this->x_size_]with:
&refresh_vecs_[static_cast<size_t>(j_col) * static_cast<size_t>(this->x_size_)]This preserves logic while preventing intermediate
intoverflow in the multiplication. No new methods or dependencies are needed. No import changes are required.Suggested fixes powered by Copilot Autofix. Review carefully before merging.