Linear algebra library for Rust.
Go to file
Aaron Hill 4e25bd87fb Don't call 'offset' on a dangling pointer
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.
2020-03-02 12:45:37 +01:00
.github Create FUNDING.yml 2019-10-28 14:15:03 +01:00
benches Import IsaacRng from rand_isaac instead of rand. 2020-03-02 12:45:36 +01:00
ci Fix mint tests. 2019-03-19 22:53:21 +01:00
examples Rename Real to RealField. 2019-03-25 11:21:41 +01:00
nalgebra-glm Release nalgebra 0.19.0. 2019-10-28 14:15:03 +01:00
nalgebra-lapack Release nalgebra 0.19.0. 2019-10-28 14:15:03 +01:00
src Don't call 'offset' on a dangling pointer 2020-03-02 12:45:37 +01:00
tests Cholupdate (#673) 2020-03-02 12:45:37 +01:00
.gitignore Add .idea folder to gitignore. 2018-09-13 09:23:08 +02:00
.travis.yml Fix CI (#634) 2019-08-27 22:05:28 +02:00
CHANGELOG.md Update changelog. 2019-08-27 22:05:28 +02:00
Cargo.toml Import IsaacRng from rand_isaac instead of rand. 2020-03-02 12:45:36 +01:00
LICENSE Initial commit. 2013-05-14 11:34:28 +00:00
Makefile Add matrix slice construction from array slices. 2018-02-03 13:59:05 +01:00
README.md HTTPS All The Things (#608) 2019-08-27 22:05:28 +02:00
rustfmt.toml Add rustfmt.toml. 2018-11-06 18:32:31 +01:00

README.md

crates.io

Build status crates.io

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:

Become a Patron!