From c2c324c49755a8e4932d01fba931d1d517b22d71 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sun, 24 May 2020 00:19:33 +0200 Subject: [PATCH] sb: fix error: applying zero offset to null pointer Found by UndefinedBehaviorSanitizer --- src/bin/sb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/sb.c b/src/bin/sb.c index defe4b01..66d11df5 100644 --- a/src/bin/sb.c +++ b/src/bin/sb.c @@ -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; } }