Skip to content

Commit 3f944c1

Browse files
committed
Fix close double-closing file
1 parent 638f039 commit 3f944c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

netcdf/src/file.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use super::group::{Group, GroupMut};
1313
use super::types::{NcTypeDescriptor, NcVariableType};
1414
use super::variable::{Variable, VariableMut};
1515
use crate::group::{get_parent_ncid_and_stem, try_get_ncid, try_get_parent_ncid_and_stem};
16-
use crate::utils::{checked_with_lock, with_lock};
16+
use crate::utils::checked_with_lock;
1717

1818
#[derive(Debug)]
1919
#[repr(transparent)]
@@ -23,7 +23,8 @@ pub(crate) struct RawFile {
2323

2424
impl RawFile {
2525
fn close(self) -> error::Result<()> {
26-
let Self { ncid } = self;
26+
let ncid = self.ncid;
27+
std::mem::forget(self);
2728
checked_with_lock(|| unsafe { nc_close(ncid) })
2829
}
2930
}

0 commit comments

Comments
 (0)