aboutsummaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2015-05-18 10:15:49 -0600
committerBen Johnson <benbjohnson@yahoo.com>2015-05-18 10:15:49 -0600
commit2c5801beddf0f53eeb75b3e10cb5f749b92e4b54 (patch)
tree5874b1f0aec574c370d948e26e04699c90d760eb /node.go
parentMerge pull request #366 from benbjohnson/sync (diff)
parentAdd inline documentation for bdc109b. (diff)
downloaddedo-2c5801beddf0f53eeb75b3e10cb5f749b92e4b54.tar.gz
dedo-2c5801beddf0f53eeb75b3e10cb5f749b92e4b54.tar.xz
Merge branch 'fix-crash'
Diffstat (limited to 'node.go')
-rw-r--r--node.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/node.go b/node.go
index 05aefb8..c9fb21c 100644
--- a/node.go
+++ b/node.go
@@ -221,11 +221,20 @@ func (n *node) write(p *page) {
_assert(elem.pgid != p.id, "write: circular dependency occurred")
}
+ // If the length of key+value is larger than the max allocation size
+ // then we need to reallocate the byte array pointer.
+ //
+ // See: https://github.com/boltdb/bolt/pull/335
+ klen, vlen := len(item.key), len(item.value)
+ if len(b) < klen+vlen {
+ b = (*[maxAllocSize]byte)(unsafe.Pointer(&b[0]))[:]
+ }
+
// Write data for the element to the end of the page.
copy(b[0:], item.key)
- b = b[len(item.key):]
+ b = b[klen:]
copy(b[0:], item.value)
- b = b[len(item.value):]
+ b = b[vlen:]
}
// DEBUG ONLY: n.dump()