Fixed GPF in fast-import caused by unterminated linked list.
fast-import was encounting a GPF when it ran out of free tree_entry objects but didn't know this was the cause because the last tree_entry wasn't terminated with a NULL pointer. The missing NULL pointer occurred when we allocated additional entries via xmalloc but didn't set the last tree_entry's "next" pointer to NULL. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Aug 26, 2006 at 22:38 UTC
2eb26d8454de77f45bbbfc32eed2a6c3133fe963
1 file changed
+2
-1
fast-import.c
+2
-1
@@ -520,10 +520,11 @@ static struct tree_entry* new_tree_entry()
520
unsigned int n = tree_entry_alloc;
521
total_allocd += n * sizeof(struct tree_entry);
522
avail_tree_entry = e = xmalloc(n * sizeof(struct tree_entry));
523
- while (n--) {
523
+ while (n-- > 1) {
524
*((void**)e) = e + 1;
525
e++;
526
}
527
+ *((void*)e) = NULL;
528
}
529
530
e = avail_tree_entry;