aboutsummaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-05-28 08:02:55 -0600
committerBen Johnson <benbjohnson@yahoo.com>2014-05-28 08:02:55 -0600
commitcefc3c5ebdf22b00a86b82b8461b8465f9304988 (patch)
treef06644bf5194ea505186ad9f5f272b5207ca50b4 /node.go
parentMerge pull request #174 from benbjohnson/remove-db-check (diff)
downloaddedo-cefc3c5ebdf22b00a86b82b8461b8465f9304988.tar.gz
dedo-cefc3c5ebdf22b00a86b82b8461b8465f9304988.tar.xz
Add circular dependency integrity check.
This commit adds a check to prevent circular dependencies in branch nodes. If a circular dependency occurs then a panic will be called and the commit will be prevented. This only works for a single branch level and will not recursively search the tree.
Diffstat (limited to 'node.go')
-rw-r--r--node.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/node.go b/node.go
index e345d7f..1502be0 100644
--- a/node.go
+++ b/node.go
@@ -192,6 +192,7 @@ func (n *node) write(p *page) {
elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem)))
elem.ksize = uint32(len(item.key))
elem.pgid = item.pgid
+ _assert(elem.pgid != p.id, "write: circular dependency occurred")
}
// Write data for the element to the end of the page.