Skip to content

Commit

Permalink
Fix close double-closing file
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusuMET committed Aug 9, 2024
1 parent 638f039 commit 3f944c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions netcdf/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::group::{Group, GroupMut};
use super::types::{NcTypeDescriptor, NcVariableType};
use super::variable::{Variable, VariableMut};
use crate::group::{get_parent_ncid_and_stem, try_get_ncid, try_get_parent_ncid_and_stem};
use crate::utils::{checked_with_lock, with_lock};
use crate::utils::checked_with_lock;

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

impl RawFile {
fn close(self) -> error::Result<()> {
let Self { ncid } = self;
let ncid = self.ncid;
std::mem::forget(self);
checked_with_lock(|| unsafe { nc_close(ncid) })
}
}
Expand Down

0 comments on commit 3f944c1

Please sign in to comment.