diff options
author | Johnny Wang <wangjiahao@openresty.com> | 2021-10-18 22:42:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 22:42:40 +0800 |
commit | 8dadbca8c7c26fc38e23f1f685c285450acb783e (patch) | |
tree | 0145d58add25344ce185bb23d89719144f5a487b | |
parent | 3d93d297092172eac3d52a1b3b6c1d479da5341a (diff) | |
download | lua-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 | } |