diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2024-04-15 15:38:47 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2024-04-15 15:38:47 +0000 |
commit | e861d3eb3d522a9c22c5a870526728e2a3d9fc04 (patch) | |
tree | b575807c029d1a166ca2c525b743ede41f3d66fa | |
parent | be1f98d47afc660e04320129c6dfc9cc306a85eb (diff) | |
parent | 4cc93f9381e0eddd2cac1e92c0f36b29dcd8c1ce (diff) |
xdgmimecache: Add assertion to silence static analysis false positive
See merge request xdg/xdgmime!38
-rw-r--r-- | src/xdgmimecache.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/xdgmimecache.c b/src/xdgmimecache.c index 57d7e2b..bdcd6a6 100644 --- a/src/xdgmimecache.c +++ b/src/xdgmimecache.c @@ -245,10 +245,15 @@ cache_magic_compare_to_data (XdgMimeCache *cache, size_t len, int *prio) { - xdg_uint32_t priority = GET_UINT32 (cache->buffer, offset); - xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, offset + 4); - xdg_uint32_t n_matchlets = GET_UINT32 (cache->buffer, offset + 8); - xdg_uint32_t matchlet_offset = GET_UINT32 (cache->buffer, offset + 12); + xdg_uint32_t priority, mimetype_offset, n_matchlets, matchlet_offset; + + assert (cache->buffer != NULL); + + priority = GET_UINT32 (cache->buffer, offset); + mimetype_offset = GET_UINT32 (cache->buffer, offset + 4); + n_matchlets = GET_UINT32 (cache->buffer, offset + 8); + matchlet_offset = GET_UINT32 (cache->buffer, offset + 12); + if (OUT_OF_BOUNDS (matchlet_offset, n_matchlets, 32, cache->size)) return NULL; @@ -280,6 +285,8 @@ cache_magic_lookup_data (XdgMimeCache *cache, xdg_uint32_t j; + assert (cache->buffer != NULL); + *prio = 0; list_offset = GET_UINT32 (cache->buffer, 24); |