Skip to content

Commit 55a27ae

Browse files
authored
Fix safety hole in Multi::close and hide it from docs (#342)
Fixes #340.
1 parent ecc9d80 commit 55a27ae

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/multi.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,19 +696,23 @@ impl Multi {
696696
}
697697
}
698698

699-
/// Attempt to close the multi handle and clean up all associated resources.
699+
/// Does nothing and returns `Ok(())`. This method remains for backwards
700+
/// compatibility.
700701
///
701-
/// Cleans up and removes a whole multi stack. It does not free or touch any
702-
/// individual easy handles in any way - they still need to be closed
703-
/// individually.
702+
/// This method will be changed to take `self` in a future release.
703+
#[doc(hidden)]
704704
pub fn close(&self) -> Result<(), MultiError> {
705-
unsafe { cvt(curl_sys::curl_multi_cleanup(self.raw)) }
705+
Ok(())
706706
}
707707

708708
/// Get a pointer to the raw underlying CURLM handle.
709709
pub fn raw(&self) -> *mut curl_sys::CURLM {
710710
self.raw
711711
}
712+
713+
unsafe fn close_impl(&self) -> Result<(), MultiError> {
714+
cvt(curl_sys::curl_multi_cleanup(self.raw))
715+
}
712716
}
713717

714718
fn cvt(code: curl_sys::CURLMcode) -> Result<(), MultiError> {
@@ -727,7 +731,7 @@ impl fmt::Debug for Multi {
727731

728732
impl Drop for Multi {
729733
fn drop(&mut self) {
730-
let _ = self.close();
734+
let _ = unsafe { self.close_impl() };
731735
}
732736
}
733737

0 commit comments

Comments
 (0)