ref: cb88262dcfd151367d2a168f2b88034132ddc6c4
parent: 5f4bc3535731f025153ee9b21af7fb8cbf8c3fc6
author: Ori Bernstein <[email protected]>
date: Thu Dec 7 13:35:54 EST 2023
tree: check for nil block at tail of path when scanning a tree, we may be at the end of the values, but not at the end of the messages during our first iter of the scan; in this case, we don't load up the blocks in the path, which can lead to a crash. This bug can also manifest persistently, which can make a file system that's not corrupt appear scratched.
--- a/tree.c
+++ b/tree.c
@@ -1475,7 +1475,7 @@
}
for(i = h-2; i >= 0; i--){
- if(p[i].bi == p[i].b->nbuf)
+ if(p[i].b == nil || p[i].bi == p[i].b->nbuf)
continue;
getmsg(p[i].b, p[i].bi, &n);
if(keycmp(&n, &m) < 0){
@@ -1497,7 +1497,7 @@
else
p[bufsrc].bi++;
for(i = h-2; i >= 0; i--){
- for(j = p[i].bi; j < p[i].b->nbuf; j++){
+ for(j = p[i].bi; p[i].b != nil && j < p[i].b->nbuf; j++){
getmsg(p[i].b, j, &m);
if(keycmp(r, &m) != 0)
break;