aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Wang <wangjiahao@openresty.com>2021-10-18 22:42:40 +0800
committerGitHub <noreply@github.com>2021-10-18 22:42:40 +0800
commit8dadbca8c7c26fc38e23f1f685c285450acb783e (patch)
tree0145d58add25344ce185bb23d89719144f5a487b
parent3d93d297092172eac3d52a1b3b6c1d479da5341a (diff)
downloadlua-cjson-8dadbca8c7c26fc38e23f1f685c285450acb783e.tar.gz
lua-cjson-8dadbca8c7c26fc38e23f1f685c285450acb783e.tar.bz2
lua-cjson-8dadbca8c7c26fc38e23f1f685c285450acb783e.zip
bugfix: fixed a possible division by zero bugs found by cppcheck. (#75)
-rw-r--r--strbuf.c2
1 files changed, 1 insertions, 1 deletions
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)
150 /* Exponential sizing */ 150 /* Exponential sizing */
151 while (newsize < reqsize) 151 while (newsize < reqsize)
152 newsize *= -s->increment; 152 newsize *= -s->increment;
153 } else { 153 } else if (s->increment != 0) {
154 /* Linear sizing */ 154 /* Linear sizing */
155 newsize = ((newsize + s->increment - 1) / s->increment) * s->increment; 155 newsize = ((newsize + s->increment - 1) / s->increment) * s->increment;
156 } 156 }