sb: fix error: applying zero offset to null pointer

Found by UndefinedBehaviorSanitizer
This commit is contained in:
Boris Faure 2020-05-24 00:19:33 +02:00
parent 04a47e0e19
commit c2c324c497
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
1 changed files with 2 additions and 1 deletions

View File

@ -146,7 +146,8 @@ ty_sb_lskip(struct ty_sb *sb, size_t len)
else
{
/* buffer is empty, get rid of gap */
sb->buf -= sb->gap;
if (sb->buf)
sb->buf -= sb->gap;
sb->gap = 0;
}
}