Fixed a memory leak in _SplitNode() spotted by Stefano - thanks!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21200 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1117,6 +1117,8 @@ BPlusTree::_SplitNode(bplustree_node *node, off_t nodeOffset,
|
|||||||
newKey = (uint8 *)malloc(newLength);
|
newKey = (uint8 *)malloc(newLength);
|
||||||
if (newKey == NULL)
|
if (newKey == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
newAllocated = true;
|
||||||
memcpy(newKey, droppedKey, newLength);
|
memcpy(newKey, droppedKey, newLength);
|
||||||
|
|
||||||
other->overflow_link = inKeyValues[in];
|
other->overflow_link = inKeyValues[in];
|
||||||
@@ -1168,8 +1170,11 @@ BPlusTree::_SplitNode(bplustree_node *node, off_t nodeOffset,
|
|||||||
} else if (keyIndex < skip)
|
} else if (keyIndex < skip)
|
||||||
bytesBefore = node->AllKeyLength() - total;
|
bytesBefore = node->AllKeyLength() - total;
|
||||||
|
|
||||||
if (bytesBefore < 0 || bytesAfter < 0)
|
if (bytesBefore < 0 || bytesAfter < 0) {
|
||||||
|
if (newAllocated)
|
||||||
|
free(newKey);
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
node->left_link = HOST_ENDIAN_TO_BFS_INT64(otherOffset);
|
node->left_link = HOST_ENDIAN_TO_BFS_INT64(otherOffset);
|
||||||
// right link, and overflow link can stay the same
|
// right link, and overflow link can stay the same
|
||||||
|
|||||||
Reference in New Issue
Block a user