Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80d5d49

Browse filesBrowse files
Fix potential integer handling issue in radixtree.h.
Coverity complained about the integer handling issue; if we start with an arbitrary non-negative shift value, the loop may decrement it down to something less than zero before exiting. This commit adds an assertion to make sure the 'shift' is always 0 after the loop, and uses 0 as the shift to get the key chunk in the following operation. Introduced by ee1b30f. Reported-by: Tom Lane as per coverity Reviewed-by: Tom Lane Discussion: https://postgr.es/m/2089517.1711299216%40sss.pgh.pa.us
1 parent 66c0185 commit 80d5d49
Copy full SHA for 80d5d49

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed

‎src/include/lib/radixtree.h

Copy file name to clipboardExpand all lines: src/include/lib/radixtree.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,10 +1615,11 @@ RT_EXTEND_DOWN(RT_RADIX_TREE * tree, RT_PTR_ALLOC * parent_slot, uint64 key, int
16151615
node = child;
16161616
shift -= RT_SPAN;
16171617
}
1618+
Assert(shift == 0);
16181619

16191620
/* Reserve slot for the value. */
16201621
n4 = (RT_NODE_4 *) node.local;
1621-
n4->chunks[0] = RT_GET_KEY_CHUNK(key, shift);
1622+
n4->chunks[0] = RT_GET_KEY_CHUNK(key, 0);
16221623
n4->base.count = 1;
16231624

16241625
return &n4->children[0];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.