From 8dadbca8c7c26fc38e23f1f685c285450acb783e Mon Sep 17 00:00:00 2001 From: Johnny Wang Date: Mon, 18 Oct 2021 22:42:40 +0800 Subject: bugfix: fixed a possible division by zero bugs found by cppcheck. (#75) --- strbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strbuf.c b/strbuf.c index f0f7f4b..ed13367 100644 --- a/strbuf.c +++ b/strbuf.c @@ -150,7 +150,7 @@ static int calculate_new_size(strbuf_t *s, int len) /* Exponential sizing */ while (newsize < reqsize) newsize *= -s->increment; - } else { + } else if (s->increment != 0) { /* Linear sizing */ newsize = ((newsize + s->increment - 1) / s->increment) * s->increment; } -- cgit v1.2.3-55-g6feb