verify that segment lengths are within reasonable boundaries (relevant for 1802.pdf.SIGSEGV.36e.894)

also prevent a double-free of segment data under OOM conditions
Merge branch 'fixes' into sumatrapdf