From e2eb8f6a28f5b4ea81c6174c013602e8a026b6cf Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 30 Sep 2024 17:53:39 +0200 Subject: [PATCH] [codec,xcrush] annotate bugprone-sizeof --- libfreerdp/codec/xcrush.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index 1d23e82cc..116d85d78 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -341,8 +341,12 @@ static int xcrush_find_next_matching_chunk(XCRUSH_CONTEXT* WINPR_RESTRICT xcrush if (chunk->next) { - UINT32 index = (chunk - xcrush->Chunks) / sizeof(XCRUSH_CHUNK); + // NOLINTNEXTLINE(bugprone-sizeof-expression) + const intptr_t diff = (chunk - xcrush->Chunks); + if (diff < 0) + return -4011; + const size_t index = (size_t)diff / sizeof(XCRUSH_CHUNK); if (index >= 65534) return -4002; /* error */