Skip to content

Commit

Permalink
Fixed IsValidRef(). Made bad checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaukala committed Dec 11, 2017
1 parent 3c346c3 commit 833993f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/PdfSharp/Pdf.IO/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,23 +1107,24 @@ private bool IsValidXref()
content += _lexer.ReadRawString(content_pos, read_length);

int ss = content.IndexOf("stream", StringComparison.Ordinal);
int eof = content.IndexOf("%%EOF", StringComparison.Ordinal);
int es = content.IndexOf("endstream", StringComparison.Ordinal);

int s = Math.Min(ss, eof);

if (s != es)
if (ss != es)
{
if (s == -1)
if (ss == -1)
return false;
else if (es == -1)
break;
else if (s < es)
else if (ss < es)
break;
else if (s > es)
else if (ss > es)
return false;
}

int eof = content.IndexOf("%%EOF", StringComparison.Ordinal);
if (eof != -1)
break;

content_pos = content_pos + read_length;
if (content_pos + read_length >= length)
{
Expand Down

0 comments on commit 833993f

Please sign in to comment.