Skip to content
Snippets Groups Projects
Unverified Commit 0996d844 authored by Ian Douglas Scott's avatar Ian Douglas Scott
Browse files

Avoid corrupting free node

parent 1e9cec60
No related branches found
No related tags found
No related merge requests found
...@@ -185,7 +185,12 @@ impl FileSystem { ...@@ -185,7 +185,12 @@ impl FileSystem {
Ok(()) Ok(())
} else { } else {
if parent.1.next == 0 { if parent.1.next == 0 {
parent.1.next = self.allocate(1)?; let next = self.allocate(1)?;
// Could be mutated by self.allocate if free block
if parent.0 == self.header.1.free {
self.read_at(parent.0, &mut parent.1)?;
}
parent.1.next = next;
self.write_at(parent.0, &parent.1)?; self.write_at(parent.0, &parent.1)?;
self.write_at(parent.1.next, &Node::default())?; self.write_at(parent.1.next, &Node::default())?;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment