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().