ViliamVadocz / nvidia-video-codec-sdk

Rust bindings for NVIDIA Video Codec SDK
MIT License
19 stars 7 forks source link

Unsound method casts mutable reference to pointer #18

Open fayalalebrun opened 3 weeks ago

fayalalebrun commented 3 weeks ago

The method in question is part of NV_ENC_INITIALIZE_PARAMS and can be found here: https://docs.rs/nvidia-video-codec-sdk/latest/src/nvidia_video_codec_sdk/safe/builders.rs.html#54-57

The problem is that this method takes a mutable reference to an NV_ENC_CONFIG. However, this is then stored to a pointer. Therefore, the NV_ENC_CONFIG member may disappear at some point while not violating any lifetime constraints.

This effectively means the NV_ENC_CONFIG may contain random data, causing strange, difficult to debug errors. Or no errors at all in some cases.