Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix npe as backport for 2.x #216

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- NPE in parser when file ends before it really starts

## [2.6.0] - 2022-06-30

### Changed
Expand Down
6 changes: 6 additions & 0 deletions src/deps/PDFWriter/PDFParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ EStatusCode PDFParser::ParseLastXrefPosition()
mObjectParser.ResetReadState();
RefCountPtr<PDFObject> anObject(mObjectParser.ParseNewObject());

if (!anObject) {
status = PDFHummus::eFailure;
TRACE_LOG("PDFParser::ParseXrefPosition: Unable to find any object");
break;
}

if(anObject->GetType() == PDFObject::ePDFObjectInteger)
{
mLastXrefPosition = (LongFilePositionType)((PDFInteger*)anObject.GetPtr())->GetValue();
Expand Down
12 changes: 12 additions & 0 deletions tests/SigSeg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var muhammara = require("../muhammara");
const { expect } = require("chai");

describe("SigSegv test", function () {
it("should read fields correctly", function () {
expect(() =>
muhammara.createReader(
__dirname + "/TestMaterials/BrokenPdfBadHeader.txt"
)
).to.throw();
});
});
2 changes: 2 additions & 0 deletions tests/TestMaterials/BrokenPdfBadHeader.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%PDF-1.4
%%EOF