gofpdi icon indicating copy to clipboard operation
gofpdi copied to clipboard

zlib.NewReader(bytes.NewBuffer(stream)) can return an error and a nil value

Open volker-schukai opened this issue 4 years ago • 1 comments

I have a pdf where the encoding does not seem to be supported, but I think you should check the error here, otherwise I get a runtime error.

runtime error: invalid memory address or nil pointer dereference

https://github.com/phpdave11/gofpdi/blob/cf771f66a372da8380cb6c9fe5d9d40133dcc563/reader.go#L509

volker-schukai avatar Apr 26 '21 12:04 volker-schukai

I'm running into the same issue, it's assuming zlib can de-compress it and is returning

// ErrHeader is returned when reading ZLIB data that has an invalid header.
ErrHeader = errors.New("zlib: invalid header")

I fixed it in my fork https://github.com/chaintraced/gofpdi/pull/1, but haven't opened a PR here yet since my previous one is still dangling. https://github.com/phpdave11/gofpdi/pull/60

johan-lejdung avatar May 02 '23 12:05 johan-lejdung