Skip to content

resolve "Multiplication result converted to larger type"#3149

Merged
wanghan-iapcm merged 1 commit intodeepmodeling:develfrom
njzjz:fix-mult-convert
Jan 17, 2024
Merged

resolve "Multiplication result converted to larger type"#3149
wanghan-iapcm merged 1 commit intodeepmodeling:develfrom
njzjz:fix-mult-convert

Conversation

@njzjz
Copy link
Member

@njzjz njzjz commented Jan 16, 2024

cast int to int64_t (for AddDim) or size_t (for resize)

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
dforce.resize(3 * static_cast<size_t>(natoms), 0);
dcoord_tmp.resize(3 * static_cast<size_t>(natoms));
dforce_tmp.resize(3 * static_cast<size_t>(natoms), 0);
msg_buff = new double[3 * static_cast<size_t>(natoms)];

Check failure

Code scanning / CodeQL

Overflow in uncontrolled allocation size

This allocation size is derived from [user input (buffer read by read)](1) and might overflow. This allocation size is derived from [user input (buffer read by read)](2) and might overflow.
@wanghan-iapcm wanghan-iapcm merged commit ed76cff into deepmodeling:devel Jan 17, 2024
wanghan-iapcm pushed a commit that referenced this pull request Jan 20, 2024
Follow up #3149.

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants