git2 has potential undefined behavior when dereferencing Buf struct
Low severity
GitHub Reviewed
Published
Feb 4, 2026
to the GitHub Advisory Database
•
Updated Feb 4, 2026
Description
Published to the GitHub Advisory Database
Feb 4, 2026
Reviewed
Feb 4, 2026
Last updated
Feb 4, 2026
If the Buf struct is dereferenced immediately after calling new() or default() on the Buf struct, a null pointer is passed to the unsafe function slice::from_raw_parts. According to the safety section documentation of the function, data must be non-null and aligned even for zero-length slices or slices of ZSTs. Thus, passing a null pointer will lead to undefined behavior.
References