BUG/MINOR: pattern: Do not pass len = 0 to calloc()
authorTim Duesterhus <tim@bastelstu.be>
Tue, 17 Mar 2020 20:08:24 +0000 (21:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 18 Mar 2020 04:17:28 +0000 (05:17 +0100)
commitb584b4475be09a20dea07f35c605487a1b73425e
treec0f5d64062b3d59d285e833fd76687c9760a1452
parenta64593c80ddd4c73af09491140786537de3b4a16
BUG/MINOR: pattern: Do not pass len = 0 to calloc()

The behavior of calloc() when being passed `0` as `nelem` is implementation
defined. It may return a NULL pointer.

Avoid this issue by checking before allocating. While doing so adjust the local
integer variables that are used to refer to memory offsets to `size_t`.

This issue was introced in commit f91ac19299fe216a793ba6550dca06b688b31549. This
patch should be backported together with that commit.
src/pattern.c