Skip to content

Commit

Permalink
Merge pull request #148 from juniorschroder/master
Browse files Browse the repository at this point in the history
fix: fix negative index error on RemoveUnusedNode when open pdf with …
  • Loading branch information
VahidN authored Jul 24, 2024
2 parents 03cf227 + 7b84b45 commit 5618985
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/iTextSharp.LGPLv2.Core/iTextSharp/text/pdf/PdfReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4142,7 +4142,7 @@ protected internal void RemoveUnusedNode(PdfObject obj, bool[] hits)
var refi = (PrIndirectReference)obj;
var num = refi.Number;

if (!hits[num])
if (num > 0 && !hits[num])
{
hits[num] = true;
state.Push(GetPdfObjectRelease(refi));
Expand Down Expand Up @@ -4180,7 +4180,7 @@ protected internal void RemoveUnusedNode(PdfObject obj, bool[] hits)
{
var num = ((PrIndirectReference)v).Number;

if (num >= _xrefObj.Count || (!_partial && _xrefObj[num] == null))
if (num > 0 && (num >= _xrefObj.Count || (!_partial && _xrefObj[num] == null)))
{
ar[k] = PdfNull.Pdfnull;

Expand Down Expand Up @@ -4217,7 +4217,7 @@ protected internal void RemoveUnusedNode(PdfObject obj, bool[] hits)
{
var num = ((PrIndirectReference)v).Number;

if (num >= _xrefObj.Count || (!_partial && _xrefObj[num] == null))
if (num > 0 && (num >= _xrefObj.Count || (!_partial && _xrefObj[num] == null)))
{
dic.Put(key, PdfNull.Pdfnull);

Expand Down

0 comments on commit 5618985

Please sign in to comment.