summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL/TreeNode.cpp
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-11-26 01:17:43 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-26 09:15:34 +0100
commit70a7bca92014b1698c3bfc80e7d61725b9b3222f (patch)
tree1e65b1df0a44224130c25b21ab283d9675f00a9c /Userland/Libraries/LibSQL/TreeNode.cpp
parente5e00a682ba321375b465f1f49c1021e8cd700cd (diff)
downloadserenity-70a7bca92014b1698c3bfc80e7d61725b9b3222f.zip
LibSQL: Fix BTree corruption in `TreeNode::split`
After splitting a node, the new node was written to the same pointer as the current node - probably a copy / paste error. This new code requires a `.pointer() -> u32` to exist on the object to be serialized, preventing this issue from happening again. Fixes #15844.
Diffstat (limited to 'Userland/Libraries/LibSQL/TreeNode.cpp')
-rw-r--r--Userland/Libraries/LibSQL/TreeNode.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibSQL/TreeNode.cpp b/Userland/Libraries/LibSQL/TreeNode.cpp
index 749570e2cb..17759d0df5 100644
--- a/Userland/Libraries/LibSQL/TreeNode.cpp
+++ b/Userland/Libraries/LibSQL/TreeNode.cpp
@@ -172,7 +172,7 @@ bool TreeNode::update_key_pointer(Key const& key)
if (m_entries[ix].pointer() != key.pointer()) {
m_entries[ix].set_pointer(key.pointer());
dump_if(SQL_DEBUG, "To WAL");
- tree().serializer().serialize_and_write<TreeNode>(*this, pointer());
+ tree().serializer().serialize_and_write<TreeNode>(*this);
}
return true;
}
@@ -277,7 +277,7 @@ void TreeNode::just_insert(Key const& key, TreeNode* right)
split();
} else {
dump_if(SQL_DEBUG, "To WAL");
- tree().serializer().serialize_and_write(*this, pointer());
+ tree().serializer().serialize_and_write(*this);
}
return;
}
@@ -289,7 +289,7 @@ void TreeNode::just_insert(Key const& key, TreeNode* right)
split();
} else {
dump_if(SQL_DEBUG, "To WAL");
- tree().serializer().serialize_and_write(*this, pointer());
+ tree().serializer().serialize_and_write(*this);
}
}
@@ -327,9 +327,9 @@ void TreeNode::split()
auto median = m_entries.take_last();
dump_if(SQL_DEBUG, "Split Left To WAL");
- tree().serializer().serialize_and_write(*this, pointer());
+ tree().serializer().serialize_and_write(*this);
new_node->dump_if(SQL_DEBUG, "Split Right to WAL");
- tree().serializer().serialize_and_write(*new_node, pointer());
+ tree().serializer().serialize_and_write(*new_node);
m_up->just_insert(median, new_node);
}