georust / gdal

Rust bindings for GDAL
https://crates.io/crates/gdal
MIT License
359 stars 94 forks source link

DriverManage::deregister_driver() leaks memory (if it is not re-registered afterwards) #482

Open rouault opened 10 months ago

rouault commented 10 months ago

Once DriverManager::deregister_driver() has been called on a driver that driver is in a detached state. Unfortunately there's nothing in the GDAL C API to explicit delete such a driver (if there was, I guess a potential fix would be to add a bool is_detached member to struct Driver and implement drop()), but this might imply changes in ownership/lifetime of the methods related to driver. Another idea I considered would be to have deregister_driver() put the driver in a list of drivers that must be re-attached before calling GDALDestroyDriverManager(), but there's no guarantee DriverManager::destroy() is going to be called