4e25bd87fb
When creating a matrix with only one zero dimension, we end up with a matrix with a total size of zero, but a non-zero stride for elements. While such a matrix can never actually have any elements, we need to be careful with how we use the pointer associated with it. Since such a pointer will always be dangling, it can never be used with `ptr.offset`, which requires that the pointer be in-bounds or one passed the end of an allocation. Violating this results in undefined behavior. This commit adds in checks before the uses of `ptr.offset`. If we ever need to offset from a pointer when our actual allocation size is zero, we skip offsetting, and return the original pointer. This is fine because any actual use of the original or offsetted pointer would already be undefined behavior - we shoul never be trying to dereference the pointer associated with a zero-size matrix. This issue was caught be running `cargo miri test` on the project. |
||
---|---|---|
.github | ||
benches | ||
ci | ||
examples | ||
nalgebra-glm | ||
nalgebra-lapack | ||
src | ||
tests | ||
.gitignore | ||
.travis.yml | ||
CHANGELOG.md | ||
Cargo.toml | ||
LICENSE | ||
Makefile | ||
README.md | ||
rustfmt.toml |
README.md
Users guide | Documentation | Forum
Linear algebra library for the Rust programming language.
Click this button if you wish to donate to support the development of nalgebra: