Skip to content

Commit 90b278d

Browse files
committed
Fix npe as backport for 2.x
Fixes #214
1 parent 9713a09 commit 90b278d

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- NPE in parser when file ends before it really starts
13+
1014
## [2.6.0] - 2022-06-30
1115

1216
### Changed

Diff for: src/deps/PDFWriter/PDFParser.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ EStatusCode PDFParser::ParseLastXrefPosition()
352352
mObjectParser.ResetReadState();
353353
RefCountPtr<PDFObject> anObject(mObjectParser.ParseNewObject());
354354

355+
if (!anObject) {
356+
status = PDFHummus::eFailure;
357+
TRACE_LOG("PDFParser::ParseXrefPosition: Unable to find any object");
358+
break;
359+
}
360+
355361
if(anObject->GetType() == PDFObject::ePDFObjectInteger)
356362
{
357363
mLastXrefPosition = (LongFilePositionType)((PDFInteger*)anObject.GetPtr())->GetValue();

Diff for: tests/SigSeg.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var muhammara = require("../muhammara");
2+
const { expect } = require("chai");
3+
4+
describe("SigSegv test", function () {
5+
it("should read fields correctly", function () {
6+
expect(() =>
7+
muhammara.createReader(
8+
__dirname + "/TestMaterials/BrokenPdfBadHeader.txt"
9+
)
10+
).to.throw();
11+
});
12+
});

Diff for: tests/TestMaterials/BrokenPdfBadHeader.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
%PDF-1.4
2+
%%EOF

0 commit comments

Comments
 (0)