util/fossilize_db: Reset file position to parsed_offset on cache_offset read failure.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 5 Aug 2021 01:03:48 +0000 (03:03 +0200)
committerMarge Bot <eric+marge@anholt.net>
Sat, 7 Aug 2021 20:06:31 +0000 (20:06 +0000)
Otherwise we might restart reading from the middle of the entry.

Fixes: 2ec1bff0f3a "util/fossilize_db: Split out reading the index."
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12204>

src/util/fossilize_db.c

index 8a38081..6737cf2 100644 (file)
@@ -157,7 +157,7 @@ update_foz_index(struct foz_db *foz_db, FILE *db_idx, unsigned file_idx)
       uint64_t cache_offset;
       if (fread(&cache_offset, 1, sizeof(cache_offset), db_idx) !=
           sizeof(cache_offset))
-         return;
+         break;
 
       entry->offset = cache_offset;