Skip to content

Commit

Permalink
Fix #771
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Jan 29, 2024
1 parent 45f8468 commit 793c509
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/pdfcpu/stamp.go
Expand Up @@ -1256,8 +1256,10 @@ func updatePageContentsForWM(ctx *model.Context, obj types.Object, wm model.Wate
wm.Objs[objNr] = true

case types.Array:

// Get stream dict for first array element.
if len(o) == 0 {
return nil
}
o1 := o[0]
ir, _ := o1.(types.IndirectRef)
objNr = ir.ObjectNumber.Value()
Expand Down Expand Up @@ -1824,6 +1826,9 @@ func removeArtifacts1(ctx *model.Context, o types.Object, entry *model.XRefTable

if len(o) > 1 {
// Get stream dict for last element.
if len(o) == 0 {
return false, nil
}
o1 := o[len(o)-1]
ir, _ := o1.(types.IndirectRef)
objNr = ir.ObjectNumber.Value()
Expand Down Expand Up @@ -2030,6 +2035,9 @@ func findPageWatermarks(ctx *model.Context, pageDictIndRef *types.IndirectRef) (

case types.Array:
// Get stream dict for first element.
if len(o) == 0 {
return false, nil
}
o1 := o[0]
ir, _ := o1.(types.IndirectRef)
objNr := ir.ObjectNumber.Value()
Expand Down
4 changes: 4 additions & 0 deletions pkg/pdfcpu/validate/page.go
Expand Up @@ -102,6 +102,10 @@ func validatePageContents(xRefTable *model.XRefTable, d types.Dict) (hasContents

}

if xRefTable.ValidationMode != model.ValidationRelaxed {
return false, errors.Errorf("validatePageContents: empty page content array detected")
}

default:
return false, errors.Errorf("validatePageContents: page content must be stream dict or array")
}
Expand Down

0 comments on commit 793c509

Please sign in to comment.