summaryrefslogtreecommitdiffstats
path: root/src/sord.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-12-11 18:59:43 -0500
committerDavid Robillard <d@drobilla.net>2024-12-11 19:37:21 -0500
commite1671ccdda0b501e27dd5afdbe05bb31656409a3 (patch)
tree9604b7fb1ea31c2959fbcc6f9c10ad13af215e82 /src/sord.c
parent34d7e6eb5b0a8a8cc218f96037fbca02849602cb (diff)
downloadsord-e1671ccdda0b501e27dd5afdbe05bb31656409a3.tar.gz
sord-e1671ccdda0b501e27dd5afdbe05bb31656409a3.tar.bz2
sord-e1671ccdda0b501e27dd5afdbe05bb31656409a3.zip
Calculate node header hash from a separate variable
Really just to avoid passing a buffer smaller than 64 bits to zix_digest(). Although that's safe (it doesn't read beyond the provided size), this is beyond some static analysis tools. So, avoid false positives by first copying the relevant header to a size_t variable making it statically obvious that (on 64-bit) 8 bytes of memory are available for reading.
Diffstat (limited to 'src/sord.c')
-rw-r--r--src/sord.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/sord.c b/src/sord.c
index 218c152..228bbac 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -169,10 +169,12 @@ sord_node_record_key(const SordNode* n)
static size_t
sord_node_hash(const SordNode* const node)
{
+ const size_t head = node->node.type;
+
size_t hash = 0U;
hash = zix_digest(hash, (const uint8_t*)node->node.buf, node->node.n_bytes);
- hash = zix_digest(hash, &node->node.type, sizeof(node->node.type));
+ hash = zix_digest(hash, &head, sizeof(head));
if (node->node.type == SERD_LITERAL) {
hash = zix_digest(hash, &node->meta.lit, sizeof(node->meta.lit));
}