Skip to content

Commit

Permalink
Fix #786
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Jan 30, 2024
1 parent ac6f14a commit dae09eb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/pdfcpu/read.go
Expand Up @@ -2187,11 +2187,13 @@ func readStreamContentBlindly(rd io.Reader) (buf []byte, err error) {
return nil, err
}

var i int
for i = -1; i < 0; i = bytes.Index(buf, []byte("endstream")) {
buf, err = growBufBy(buf, defaultBufSize, rd)
if err != nil {
return nil, err
i := bytes.Index(buf, []byte("endstream"))
if i < 0 {
for i = -1; i < 0; i = bytes.Index(buf, []byte("endstream")) {
buf, err = growBufBy(buf, defaultBufSize, rd)
if err != nil {
return nil, err
}
}
}

Expand Down Expand Up @@ -2289,7 +2291,7 @@ func loadEncodedStreamContent(c context.Context, ctx *model.Context, sd *types.S
}

l1 := 0
if !fixLength {
if sd.StreamLength != nil {
l1 = int(*sd.StreamLength)
}
rawContent, err := readStreamContent(rd, l1)
Expand Down

0 comments on commit dae09eb

Please sign in to comment.