galkahana / PDF-Writer

High performance library for creating, modiyfing and parsing PDF files in C++
http://www.pdfhummus.com
Apache License 2.0
900 stars 215 forks source link

infinite loop #235

Closed Macintron closed 10 months ago

Macintron commented 10 months ago

Found with clang-tidy bugprone-infinite-loop:

https://github.com/galkahana/PDF-Writer/blob/a514170d729f06b4fb6395b0e31b7712a77c6b02/PDFWriter/CharStringType2Interpreter.cpp#L1088C11-L1088C11

CharStringType2Interpreter::InterpretIndex()
...
    long index = (value.IsInteger ? value.IntegerValue : (long)value.RealValue);
    CharStringOperandList::reverse_iterator it = mOperandStack.rbegin();
    while(index > 0)
        ++it;
galkahana commented 10 months ago

added iterator check.

while at it also saw some other places in this class that could use a bit of verification prior to manipulating the stack.

think this should work: https://github.com/galkahana/PDF-Writer/pull/236

Macintron commented 10 months ago

Thank you