From 8bea21ec200e7fed6aa63e3cb3d893e7818e1a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Wed, 5 Jul 2023 14:43:57 +0300 Subject: [PATCH] Fix use-after-free in Dataset::close --- CHANGES.md | 4 ++++ src/dataset.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index e42dd5da..e108cb31 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ # Changes ## Unreleased +- `Dataset::close` now consumes `self` + + - + - Fixed build error with GDAL 3.1 - diff --git a/src/dataset.rs b/src/dataset.rs index e02487da..788b136d 100644 --- a/src/dataset.rs +++ b/src/dataset.rs @@ -429,7 +429,7 @@ impl Dataset { /// See [`GDALClose`]. /// /// Note: on GDAL versions older than 3.7, this function always succeeds. - pub fn close(&mut self) -> Result<()> { + pub fn close(self) -> Result<()> { #[cfg(any(all(major_ge_3, minor_ge_7), major_ge_4))] { let rv = unsafe { gdal_sys::GDALClose(self.c_dataset) };