当目录对象无法解析时,EnsurePageCount 会发生 nil 指针解引用异常
作者: smileexpression创建于 2026年9月6日更新于 2026年9月7日
标签bug
Each layer assumes "err == nil ⇒ value non-nil", but the invariant is broken at the first one: 1. Per spec 7.3.10, `indRefToObject` returns the null object "without error" for the unresolvable root reference. 2. `Catalog()` (xreftable.go:1097–1100, v0.15.0) propagates this as `(nil, nil)`: o, _, err := xRefTable.indRefToObject(xRefTable.Root, true) if err != nil || o == nil { return nil, err } 3. `Pages()` (xreftable.go:1145) calls `IndirectRefEntry("Pages")` on the nil dict and returns `(nil, nil)`. 4. `EnsurePageCount()` (xreftable.go:2191) dereferences *pageRoot without a nil check: d, err := xRefTable.DereferenceDict(*pageRoot)
内容来源: pdfcpu/pdfcpu