scylladb / cpp-rust-driver

API-compatible rewrite of https://github.com/scylladb/cpp-driver as a wrapper for Rust driver.
GNU Lesser General Public License v2.1
11 stars 11 forks source link

Avoid creating references to uninitialized data #97

Closed Lorak-mmk closed 1 year ago

Lorak-mmk commented 1 year ago

Creating a reference to uninitialized data is most of the time undefined behaviour in Rust - even if data under this reference is never read.

This commit removes all occurences of this problem (in accordance with cpp-driver's semantics), instead using std::ptr::write - safer and more explicit way to achieve the same goal.

Pre-review checklist

Lorak-mmk commented 1 year ago

it is not obvious from the documentation what will happen if it gets a null pointer as a destination location

Documentation states it is undefined behavior.

cppdriver also doesn't check for null outputs and would also exhibit UB in that case, so there is no regression on that front. I can add null checks, but it would be just a hardening measure, not required for corectness of this project.