phpdave11 / gofpdi

Go Free PDF Document Importer
MIT License
118 stars 59 forks source link

runtime error: invalid memory address or nil pointer dereference #28

Closed rorycl closed 4 years ago

rorycl commented 4 years ago

The file at http://www.campbell-lange.net/media/files/example6.pdf causes the following error:

file: /tmp/f4a42574-28b8-4fc8-8322-fdbd885f10f3.pdf
   pages:   2
   page :   1 processed
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x5407b6]

goroutine 1 [running]:
github.com/phpdave11/gofpdi.(*PdfReader).rebuildContentStream(0xc00007a1e0, 0xc0002623c0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.11/reader.go:1376 +0xb6
github.com/phpdave11/gofpdi.(*PdfReader).getContent(0xc00007a1e0, 0x2, 0xc00022d860, 0x0, 0x0, 0x1)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.11/reader.go:1329 +0x1f3
github.com/phpdave11/gofpdi.(*PdfWriter).ImportPage(0xc00016cc80, 0xc00007a1e0, 0x2, 0x5c1e52, 0x9, 0x1, 0x0, 0x0)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.11/writer.go:148 +0x163
github.com/phpdave11/gofpdi.(*Importer).ImportPage(0xc0000a5480, 0x2, 0x5c1e52, 0x9, 0x0)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.11/importer.go:122 +0x103
github.com/phpdave11/gofpdf/contrib/gofpdi.(*Importer).getTemplateID(0xc00009e570, 0x60a0c0, 0xc000124000, 0x2, 0x5c1e52, 0x9, 0x7)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdf@v1.4.1-0.20200211150905-48c1f7f2764c/contrib/gofpdi/gofpdi.go:61 +0x50
github.com/phpdave11/gofpdf/contrib/gofpdi.(*Importer).ImportPage(0xc00009e570, 0x60a0c0, 0xc000124000, 0x7fffdeeeb5f7, 0x2d, 0x2, 0x5c1e52, 0x9, 0x0)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdf@v1.4.1-0.20200211150905-48c1f7f2764c/contrib/gofpdi/gofpdi.go:45 +0x89
github.com/phpdave11/gofpdf/contrib/gofpdi.ImportPage(...)
    /home/rory/go/pkg/mod/github.com/phpdave11/gofpdf@v1.4.1-0.20200211150905-48c1f7f2764c/contrib/gofpdi/gofpdi.go:115
main.main()
    /home/rory/src/go-gofpdi-test/gofpdi-t3.go:47 +0x214

Please note that this file will be removed shortly.

rorycl commented 4 years ago

Closing as #37 has an example file.