mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 22:30:11 +01:00
util/mesa-db: Fix crash on compacting empty DB
Fix mesa_db_compact() segfaulting if compacted DB is empty. This crash happens on writing cache entry that is bigger than DB's size limit and when DB is empty, which can be triggered by setting DB size to a small value. Fixes:32211788d0("util/disk_cache: Add new mesa-db cache type") Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Acked-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30988> (cherry picked from commit5ec424c6be)
This commit is contained in:
parent
1421945edd
commit
ffbb9de588
2 changed files with 4 additions and 1 deletions
|
|
@ -524,7 +524,7 @@
|
|||
"description": "util/mesa-db: Fix crash on compacting empty DB",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "32211788d05311d1a92863e5445b56a5175ad4a0",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -524,6 +524,9 @@ mesa_db_compact(struct mesa_cache_db *db, int64_t blob_size,
|
|||
return false;
|
||||
|
||||
num_entries = _mesa_hash_table_num_entries(db->index_db->table);
|
||||
if (!num_entries)
|
||||
return true;
|
||||
|
||||
entries = calloc(num_entries, sizeof(*entries));
|
||||
if (!entries)
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue