fix UBSanitizer issue: applying non-zero offset to null pointer

This commit is contained in:
Karel Miko 2026-05-03 18:32:21 +02:00
parent 5c8ac18bd1
commit 661fcd6486

View file

@ -56,8 +56,11 @@ static LTC_INLINE int s_bufp_fits(struct bufp *buf, unsigned long to_write)
{
char *d = buf->work;
char *e = buf->end;
char *w = d + to_write;
if (d == NULL || w < d || w > e)
char *w;
if (d == NULL || e == NULL)
return 0;
w = d + to_write;
if (w < d || w > e)
return 0;
return 1;
}