diff --git a/src/tfile.cpp b/src/tfile.cpp index 9d56af6..92ce9e9 100644 --- a/src/tfile.cpp +++ b/src/tfile.cpp @@ -339,7 +339,7 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data // collect free slots TFile_Free_Slot fs; u64 free_slot_size = sizeof(u16) + (is_big_file ? sizeof(fs.rng.rng_long) : sizeof(fs.rng.rng_short)); - u64 free_slots_start = tkeys_data.sections[Sec_TFile_FreeList].range.start + 65; // XXX: the keylen should be subtracted above! + u64 free_slots_start = tkeys_data.sections[Sec_TFile_FreeList].range.start; u64 free_slots_end = tkeys_data.sections[Sec_TFile_FreeList].range.end(); u64 n_free_slots = (free_slots_end - free_slots_start) / free_slot_size; if (n_free_slots) { @@ -368,6 +368,7 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data free_slot->len = end - start + 1; // +1 because `end` is inclusive ++i; } else { + assert(n_free_slots > 0); --n_free_slots; } }