Advisory

RUSTSEC-2026-0197

Also known as: None

Summary

Matrix{2,3,4}::swap_columns can trigger undefined behavior for identical indices

Details

The Matrix2::swap_columns, Matrix3::swap_columns, and Matrix4::swap_columns
implementations call ptr::swap(&mut self[a], &mut self[b]).

When a == b, these safe APIs create two mutable references to the same matrix
column and pass them to ptr::swap. This violates Rust's aliasing rules and can
trigger undefined behavior. The issue can be reproduced from safe Rust by calling
swap_columns with identical column indices, for example m.swap_columns(0, 0).

A minimal fix is to return early when the two column indices are equal before
calling ptr::swap.

Severity

Not rated by the source.

Dates

Published
2026-03-11 12:00 UTC
Modified
2026-07-03 13:45 UTC

Affected packages and fixes

cgmath

crates.io · All systems

Affected

  • introduced 0.0.0-0 (semver)

Fixed versions

None listed

Fix

No fixed version is listed.

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: RustSec Advisory Database · CC0-1.0

Sources & licences