JBIG2Stream: fix leak in reset() if called several times

JBIG2Stream::reset() currently allocates new values for the
segments and globalSegments member variable. This causes a
memory leak if the method is called several times, which can
be triggered by the GDAL library that uses Poppler.
So add a freeSegments() method where we move the related cleanup
of close(), and call that method from reset() and close().
6 jobs for fix_leak_in_jbig2stream in 12 minutes and 57 seconds (queued for 2 seconds)
latest
Status Job ID Name Coverage
  Build
passed #1044185
build

00:12:49

passed #1044190
build_android

00:00:38

passed #1044186
build_clang_libcpp

00:12:57

passed #1044189
build_clazy

00:08:09

passed #1044188
build_mingw64_fedora

00:03:03

passed #1044187
build_ubuntu_16_04

00:08:51