util: skip zero-sized SHA1Update

Fixes UBSan error:
src/util/sha1/sha1.c:140:8: runtime error: null pointer passed as argument 2, which is declared to never be null

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25853>
This commit is contained in:
Rhys Perry 2023-09-27 15:55:25 +01:00 committed by Marge Bot
parent 1afd0878e9
commit 477b310dfd

View file

@ -44,7 +44,8 @@ _mesa_sha1_init(struct mesa_sha1 *ctx)
static inline void
_mesa_sha1_update(struct mesa_sha1 *ctx, const void *data, size_t size)
{
SHA1Update(ctx, (const unsigned char *)data, size);
if (size)
SHA1Update(ctx, (const unsigned char *)data, size);
}
static inline void