muhammara 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.5.0] - 2022-12-07
11
+
12
+ ### Added
13
+
14
+ - Electron 22.0.x
15
+
16
+ ## [3.4.0] - 2022-11-24
17
+
18
+ ### Added
19
+
20
+ - Electron 21.3.x
21
+
22
+ ### Fixed
23
+
24
+ - Several cases of NPE under different circumstances
25
+
10
26
  ## [3.3.0] - 2022-11-05
11
27
 
12
28
  ### Fixed
@@ -72,6 +88,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
72
88
  - Node < 11 and Electron < 11 removed
73
89
  - Renamed typo exported value from eTokenSeprator to eTokenSeparator
74
90
 
91
+ ## [2.6.2] - 2022-11-23
92
+
93
+ ### Fixed
94
+
95
+ - Several cases of NPE under different circumstances
96
+
75
97
  ## [2.6.1] - 2022-10-23
76
98
 
77
99
  ### Fixed
@@ -310,12 +332,15 @@ with the following changes.
310
332
 
311
333
  - Initial release
312
334
 
313
- [unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.3.0...HEAD
335
+ [unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.5.0...HEAD
336
+ [3.5.0]: https://github.com/julianhille/MuhammaraJS/compare/3.4.0...3.5.0
337
+ [3.4.0]: https://github.com/julianhille/MuhammaraJS/compare/3.3.0...3.4.0
314
338
  [3.3.0]: https://github.com/julianhille/MuhammaraJS/compare/3.2.0...3.3.0
315
339
  [3.2.0]: https://github.com/julianhille/MuhammaraJS/compare/3.1.1...3.2.0
316
340
  [3.1.1]: https://github.com/julianhille/MuhammaraJS/compare/3.1.0...3.1.1
317
341
  [3.1.0]: https://github.com/julianhille/MuhammaraJS/compare/3.0.0...3.1.0
318
- [3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.1...3.0.0
342
+ [3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.2...3.0.0
343
+ [2.6.2]: https://github.com/julianhille/MuhammaraJS/compare/2.6.1...2.6.2
319
344
  [2.6.1]: https://github.com/julianhille/MuhammaraJS/compare/2.6.0...2.6.1
320
345
  [2.6.0]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...2.6.0
321
346
  [2.5.0]: https://github.com/julianhille/MuhammaraJS/compare/2.4.0...2.5.0
@@ -2,39 +2,71 @@
2
2
  import { EventEmitter } from 'events'
3
3
  import { Stream } from 'stream'
4
4
 
5
- export type Encoding = BufferEncoding | 'buffer' | null
6
-
7
- interface Writable extends EventEmitter {
8
- end(): any
9
- write(chunk: any, ...args: any[]): any
10
- }
11
-
12
- interface Readable extends EventEmitter {
13
- pause(): any
14
- resume(): any
15
- pipe(): any
16
- }
17
-
18
- interface Pipe<R, W> {
19
- src: Minipass<R, W>
20
- dest: Writable
21
- opts: PipeOptions
5
+ declare namespace Minipass {
6
+ type Encoding = BufferEncoding | 'buffer' | null
7
+
8
+ interface Writable extends EventEmitter {
9
+ end(): any
10
+ write(chunk: any, ...args: any[]): any
11
+ }
12
+
13
+ interface Readable extends EventEmitter {
14
+ pause(): any
15
+ resume(): any
16
+ pipe(): any
17
+ }
18
+
19
+ interface Pipe<R, W> {
20
+ src: Minipass<R, W>
21
+ dest: Writable
22
+ opts: PipeOptions
23
+ }
24
+
25
+ type DualIterable<T> = Iterable<T> & AsyncIterable<T>
26
+
27
+ type ContiguousData = Buffer | ArrayBufferLike | ArrayBufferView | string
28
+
29
+ type BufferOrString = Buffer | string
30
+
31
+ interface StringOptions {
32
+ encoding: BufferEncoding
33
+ objectMode?: boolean
34
+ async?: boolean
35
+ }
36
+
37
+ interface BufferOptions {
38
+ encoding?: null | 'buffer'
39
+ objectMode?: boolean
40
+ async?: boolean
41
+ }
42
+
43
+ interface ObjectModeOptions {
44
+ objectMode: true
45
+ async?: boolean
46
+ }
47
+
48
+ interface PipeOptions {
49
+ end?: boolean
50
+ proxyErrors?: boolean
51
+ }
52
+
53
+ type Options<T> = T extends string
54
+ ? StringOptions
55
+ : T extends Buffer
56
+ ? BufferOptions
57
+ : ObjectModeOptions
22
58
  }
23
59
 
24
- type DualIterable<T> = Iterable<T> & AsyncIterable<T>
25
-
26
- type ContiguousData = Buffer | ArrayBufferLike | ArrayBufferView | string
27
-
28
- type BufferOrString = Buffer | string
29
-
30
- export default class Minipass<
60
+ declare class Minipass<
31
61
  RType extends any = Buffer,
32
- WType extends any = RType extends BufferOrString ? ContiguousData : RType
62
+ WType extends any = RType extends Minipass.BufferOrString
63
+ ? Minipass.ContiguousData
64
+ : RType
33
65
  >
34
66
  extends Stream
35
- implements DualIterable<RType>
67
+ implements Minipass.DualIterable<RType>
36
68
  {
37
- static isStream(stream: any): stream is Readable | Writable
69
+ static isStream(stream: any): stream is Minipass.Readable | Minipass.Writable
38
70
 
39
71
  readonly bufferLength: number
40
72
  readonly flowing: boolean
@@ -48,7 +80,7 @@ export default class Minipass<
48
80
  * Not technically private or readonly, but not safe to mutate.
49
81
  */
50
82
  private readonly buffer: RType[]
51
- private readonly pipes: Pipe<RType, WType>[]
83
+ private readonly pipes: Minipass.Pipe<RType, WType>[]
52
84
 
53
85
  /**
54
86
  * Technically writable, but mutating it can change the type,
@@ -70,31 +102,31 @@ export default class Minipass<
70
102
  * TypeScript does not provide many options for changing the type of
71
103
  * an object at run-time, which is what changing the encoding does.
72
104
  */
73
- readonly encoding: Encoding
105
+ readonly encoding: Minipass.Encoding
74
106
  // setEncoding(encoding: Encoding): void
75
107
 
76
108
  // Options required if not reading buffers
77
109
  constructor(
78
110
  ...args: RType extends Buffer
79
- ? [] | [Options<RType>]
80
- : [Options<RType>]
111
+ ? [] | [Minipass.Options<RType>]
112
+ : [Minipass.Options<RType>]
81
113
  )
82
114
 
83
115
  write(chunk: WType, cb?: () => void): boolean
84
- write(chunk: WType, encoding?: Encoding, cb?: () => void): boolean
116
+ write(chunk: WType, encoding?: Minipass.Encoding, cb?: () => void): boolean
85
117
  read(size?: number): RType
86
118
  end(cb?: () => void): this
87
119
  end(chunk: any, cb?: () => void): this
88
- end(chunk: any, encoding?: Encoding, cb?: () => void): this
120
+ end(chunk: any, encoding?: Minipass.Encoding, cb?: () => void): this
89
121
  pause(): void
90
122
  resume(): void
91
123
  promise(): Promise<void>
92
124
  collect(): Promise<RType[]>
93
125
 
94
- concat(): RType extends BufferOrString ? Promise<RType> : never
126
+ concat(): RType extends Minipass.BufferOrString ? Promise<RType> : never
95
127
  destroy(er?: any): void
96
- pipe<W extends Writable>(dest: W, opts?: PipeOptions): W
97
- unpipe<W extends Writable>(dest: W): void
128
+ pipe<W extends Minipass.Writable>(dest: W, opts?: Minipass.PipeOptions): W
129
+ unpipe<W extends Minipass.Writable>(dest: W): void
98
130
 
99
131
  /**
100
132
  * alias for on()
@@ -120,30 +152,4 @@ export default class Minipass<
120
152
  [Symbol.asyncIterator](): AsyncIterator<RType>
121
153
  }
122
154
 
123
- interface StringOptions {
124
- encoding: BufferEncoding
125
- objectMode?: boolean
126
- async?: boolean
127
- }
128
-
129
- interface BufferOptions {
130
- encoding?: null | 'buffer'
131
- objectMode?: boolean
132
- async?: boolean
133
- }
134
-
135
- interface ObjectModeOptions {
136
- objectMode: true
137
- async?: boolean
138
- }
139
-
140
- export declare interface PipeOptions {
141
- end?: boolean
142
- proxyErrors?: boolean
143
- }
144
-
145
- export declare type Options<T> = T extends string
146
- ? StringOptions
147
- : T extends Buffer
148
- ? BufferOptions
149
- : ObjectModeOptions
155
+ export = Minipass
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "minipass@^3.0.0",
3
- "_id": "minipass@3.3.4",
3
+ "_id": "minipass@3.3.6",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==",
5
+ "_integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
6
6
  "_location": "/minipass",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -20,8 +20,8 @@
20
20
  "/minizlib",
21
21
  "/tar"
22
22
  ],
23
- "_resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
24
- "_shasum": "ca99f95dd77c43c7a76bf51e6d200025eee0ffae",
23
+ "_resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
24
+ "_shasum": "7bba384db3a1520d18c9c0e5251c3444e95dd94a",
25
25
  "_spec": "minipass@^3.0.0",
26
26
  "_where": "/home/runner/work/MuhammaraJS/MuhammaraJS/node_modules/tar",
27
27
  "author": {
@@ -79,12 +79,13 @@
79
79
  },
80
80
  "scripts": {
81
81
  "postpublish": "git push origin --follow-tags",
82
- "postversion": "npm publish --tag=next",
82
+ "postversion": "npm publish",
83
83
  "preversion": "npm test",
84
84
  "test": "tap"
85
85
  },
86
86
  "tap": {
87
87
  "check-coverage": true
88
88
  },
89
- "version": "3.3.4"
89
+ "types": "index.d.ts",
90
+ "version": "3.3.6"
90
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muhammara",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Create, read and modify PDF files and streams. A drop in replacement for hummusjs PDF library",
5
5
  "homepage": "https://github.com/julianhille/Muhammarajs",
6
6
  "license": "Apache-2.0",
@@ -1018,7 +1018,13 @@ EStatusCode CFFFileInput::CalculateDependenciesForCharIndex(unsigned short inFon
1018
1018
  if(status != PDFHummus::eFailure)
1019
1019
  {
1020
1020
  mCurrentDependencies = &ioDependenciesInfo;
1021
- return interpreter.Intepret(*GetGlyphCharString(inFontIndex,inCharStringIndex),this);
1021
+ CharString* charString = GetGlyphCharString(inFontIndex,inCharStringIndex);
1022
+ if(!charString)
1023
+ {
1024
+ TRACE_LOG("GetGlyphCharString cannot find char string");
1025
+ return PDFHummus::eFailure;
1026
+ }
1027
+ return interpreter.Intepret(*charString, this);
1022
1028
  }
1023
1029
  else
1024
1030
  return status;
@@ -409,7 +409,7 @@ XCryptionCommon* DecryptionHelper::GetCryptForStream(PDFStreamInput* inStream) {
409
409
  for (; i < filterObjectArray->GetLength(); ++i)
410
410
  {
411
411
  PDFObjectCastPtr<PDFName> filterObjectItem(filterObjectArray->QueryObject(i));
412
- if (filterObjectItem->GetValue() == "Crypt")
412
+ if (!filterObjectItem || filterObjectItem->GetValue() == "Crypt")
413
413
  break;
414
414
  }
415
415
  if (i < filterObjectArray->GetLength()) {
@@ -2176,7 +2176,7 @@ EStatusCode DocumentContext::SetupModifiedFile(PDFParser* inModifiedFileParser)
2176
2176
  if(idArray.GetPtr() && idArray->GetLength() == 2)
2177
2177
  {
2178
2178
  PDFObjectCastPtr<PDFHexString> firstID = idArray->QueryObject(0);
2179
- if(firstID.GetPtr())
2179
+ if(firstID != NULL && firstID.GetPtr())
2180
2180
  mModifiedDocumentID = firstID->GetValue();
2181
2181
  }
2182
2182
 
@@ -2300,6 +2300,10 @@ EStatusCode DocumentContext::FinalizeModifiedPDF(PDFParser* inModifiedFileParser
2300
2300
  {
2301
2301
  // use an extender to copy original catalog elements and update version if required
2302
2302
  PDFDocumentCopyingContext* copyingContext = CreatePDFCopyingContext(inModifiedFileParser);
2303
+ if(!copyingContext) {
2304
+ status = eFailure;
2305
+ break;
2306
+ }
2303
2307
  ModifiedDocCatalogWriterExtension catalogUpdate(copyingContext,requiresVersionUpdate,inModifiedPDFVersion);
2304
2308
  status = WriteCatalogObject(finalPageRoot,&catalogUpdate);
2305
2309
  delete copyingContext;
@@ -2311,8 +2315,9 @@ EStatusCode DocumentContext::FinalizeModifiedPDF(PDFParser* inModifiedFileParser
2311
2315
  WriteInfoDictionary();
2312
2316
 
2313
2317
  // write encryption dictionary, if encrypting
2314
- CopyEncryptionDictionary(inModifiedFileParser);
2315
-
2318
+ status = CopyEncryptionDictionary(inModifiedFileParser);
2319
+ if(status != eSuccess)
2320
+ break;
2316
2321
  if(RequiresXrefStream(inModifiedFileParser))
2317
2322
  {
2318
2323
  status = WriteXrefStream(xrefTablePosition);
@@ -2398,8 +2403,11 @@ bool DocumentContext::DocumentHasNewPages()
2398
2403
  hasLeafs = pageTreeRoot->IsLeafParent();
2399
2404
  if(pageTreeRoot->GetNodesCount() == 0)
2400
2405
  break;
2401
- else
2406
+ else {
2402
2407
  pageTreeRoot = pageTreeRoot->GetPageTreeChild(0);
2408
+ if (!pageTreeRoot)
2409
+ break;
2410
+ }
2403
2411
  }
2404
2412
 
2405
2413
  return hasLeafs;
@@ -2526,12 +2534,12 @@ bool DocumentContext::DoExtendersRequireCatalogUpdate(PDFParser* inModifiedFileP
2526
2534
  return isUpdateRequired;
2527
2535
  }
2528
2536
 
2529
- void DocumentContext::CopyEncryptionDictionary(PDFParser* inModifiedFileParser)
2537
+ EStatusCode DocumentContext::CopyEncryptionDictionary(PDFParser* inModifiedFileParser)
2530
2538
  {
2531
2539
  // Reuse original encryption dict for new modified trailer. for sake of simplicity (with trailer using ref for encrypt), make it indirect if not already
2532
2540
  RefCountPtr<PDFObject> encrypt(inModifiedFileParser->GetTrailer()->QueryDirectObject("Encrypt"));
2533
2541
  if (encrypt.GetPtr() == NULL)
2534
- return;
2542
+ return eSuccess;
2535
2543
 
2536
2544
  if (encrypt->GetType() == PDFObject::ePDFObjectIndirectObjectReference)
2537
2545
  {
@@ -2540,11 +2548,15 @@ void DocumentContext::CopyEncryptionDictionary(PDFParser* inModifiedFileParser)
2540
2548
  }
2541
2549
  else
2542
2550
  {
2551
+ // copying context, write as is
2552
+ PDFDocumentCopyingContext* copyingContext = CreatePDFCopyingContext(inModifiedFileParser);
2553
+ if(!copyingContext) {
2554
+ return eFailure;
2555
+ }
2543
2556
  // copy to indirect object and set refrence
2544
2557
  mEncryptionHelper.PauseEncryption();
2545
2558
  ObjectIDType encryptionDictionaryID = mObjectsContext->StartNewIndirectObject();
2546
- // copying context, write as is
2547
- PDFDocumentCopyingContext* copyingContext = CreatePDFCopyingContext(inModifiedFileParser);
2559
+
2548
2560
  copyingContext->CopyDirectObjectAsIs(encrypt.GetPtr());
2549
2561
  delete copyingContext;
2550
2562
  mObjectsContext->EndIndirectObject();
@@ -2552,6 +2564,7 @@ void DocumentContext::CopyEncryptionDictionary(PDFParser* inModifiedFileParser)
2552
2564
 
2553
2565
  mTrailerInformation.SetEncrypt(encryptionDictionaryID);
2554
2566
  }
2567
+ return eSuccess;
2555
2568
  }
2556
2569
 
2557
2570
  bool DocumentContext::RequiresXrefStream(PDFParser* inModifiedFileParser)
@@ -432,7 +432,7 @@ namespace PDFHummus
432
432
  ObjectIDType WriteCombinedPageTree(PDFParser* inModifiedFileParser);
433
433
  bool IsRequiredVersionHigherThanPDFVersion(PDFParser* inModifiedFileParser,EPDFVersion inModifiedPDFVersion);
434
434
  bool DoExtendersRequireCatalogUpdate(PDFParser* inModifiedFileParser);
435
- void CopyEncryptionDictionary(PDFParser* inModifiedFileParser);
435
+ PDFHummus::EStatusCode CopyEncryptionDictionary(PDFParser* inModifiedFileParser);
436
436
  bool RequiresXrefStream(PDFParser* inModifiedFileParser);
437
437
  PDFHummus::EStatusCode WriteXrefStream(LongFilePositionType& outXrefPosition);
438
438
  HummusImageInformation& GetImageInformationStructFor(const std::string& inImageFile,unsigned long inImageIndex);
@@ -163,6 +163,8 @@ PDFHummus::EStatusCode PDFModifiedPage::WritePage()
163
163
  // get the page object
164
164
  ObjectIDType pageObjectID = copyingContext->GetSourceDocumentParser()->GetPageObjectID(mPageIndex);
165
165
  PDFObjectCastPtr<PDFDictionary> pageDictionaryObject = copyingContext->GetSourceDocumentParser()->ParsePage(mPageIndex);
166
+ if (!pageDictionaryObject)
167
+ return eFailure;
166
168
  MapIterator<PDFNameToPDFObjectMap> pageDictionaryObjectIt = pageDictionaryObject->GetIterator();
167
169
 
168
170
  // create modified page object
@@ -181,7 +181,13 @@ void PDFPageInput::SetPDFRectangleFromPDFArray(PDFArray* inPDFArray,PDFRectangle
181
181
  RefCountPtr<PDFObject> lowerLeftY(inPDFArray->QueryObject(1));
182
182
  RefCountPtr<PDFObject> upperRightX(inPDFArray->QueryObject(2));
183
183
  RefCountPtr<PDFObject> upperRightY(inPDFArray->QueryObject(3));
184
-
184
+ if (!lowerLeftX || !lowerLeftY || !upperRightX || !upperRightY)
185
+ {
186
+ // not sure if just a return is a good idea here.
187
+ // Things wont jus work and might go unnoticed
188
+ TRACE_LOG("Could not apply pdf rectangle as values are NULL");
189
+ return;
190
+ }
185
191
  outPDFRectangle.LowerLeftX = ParsedPrimitiveHelper(lowerLeftX.GetPtr()).GetAsDouble();
186
192
  outPDFRectangle.LowerLeftY = ParsedPrimitiveHelper(lowerLeftY.GetPtr()).GetAsDouble();
187
193
  outPDFRectangle.UpperRightX = ParsedPrimitiveHelper(upperRightX.GetPtr()).GetAsDouble();
@@ -396,6 +396,12 @@ EStatusCode PDFParser::ParseLastXrefPosition()
396
396
  while(!foundStartXref && mStream->NotEnded())
397
397
  {
398
398
  PDFObjectCastPtr<PDFSymbol> startxRef(mObjectParser.ParseNewObject());
399
+ if(!startxRef)
400
+ {
401
+ status = PDFHummus::eFailure;
402
+ TRACE_LOG("PDFParser::ParseXrefPosition, syntax error in reading xref position");
403
+ break;
404
+ }
399
405
  foundStartXref = startxRef.GetPtr() && (startxRef->GetValue() == scStartxref);
400
406
  }
401
407
 
@@ -68,7 +68,8 @@ EStatusCode PDFUsedFont::EncodeStringForShowing(const GlyphUnicodeMappingList& i
68
68
 
69
69
  if(!mWrittenFont)
70
70
  mWrittenFont = mFaceWrapper.CreateWrittenFontObject(mObjectsContext,mEmbedFont);
71
-
71
+ if(!mWrittenFont)
72
+ return PDFHummus::eFailure;
72
73
  mWrittenFont->AppendGlyphs(inText,outCharactersToUse,outTreatCharactersAsCID,outFontObjectToUse);
73
74
 
74
75
  return PDFHummus::eSuccess;
@@ -108,7 +109,8 @@ EStatusCode PDFUsedFont::EncodeStringsForShowing(const GlyphUnicodeMappingListLi
108
109
 
109
110
  if(!mWrittenFont)
110
111
  mWrittenFont = mFaceWrapper.CreateWrittenFontObject(mObjectsContext,mEmbedFont);
111
-
112
+ if(!mWrittenFont)
113
+ return PDFHummus::eFailure;
112
114
  mWrittenFont->AppendGlyphs(inText,outCharactersToUse,outTreatCharactersAsCID,outFontObjectToUse);
113
115
 
114
116
  return PDFHummus::eSuccess;
@@ -416,6 +416,9 @@ EStatusCode TrueTypeEmbeddedFontWriter::WriteHead()
416
416
  // and store the offset to the checksum
417
417
 
418
418
  TableEntry* tableEntry = mTrueTypeInput.GetTableEntry("head");
419
+ if (!tableEntry) {
420
+ return PDFHummus::eFailure;
421
+ }
419
422
  LongFilePositionType startTableOffset;
420
423
  OutputStreamTraits streamCopier(&mFontFileStream);
421
424
  LongFilePositionType endOfStream;
@@ -485,6 +488,9 @@ EStatusCode TrueTypeEmbeddedFontWriter::WriteHHea()
485
488
  // count is lower
486
489
 
487
490
  TableEntry* tableEntry = mTrueTypeInput.GetTableEntry("hhea");
491
+ if (!tableEntry) {
492
+ return PDFHummus::eFailure;
493
+ }
488
494
  LongFilePositionType startTableOffset;
489
495
  OutputStreamTraits streamCopier(&mFontFileStream);
490
496
  LongFilePositionType endOfStream;
@@ -556,6 +562,9 @@ EStatusCode TrueTypeEmbeddedFontWriter::WriteMaxp()
556
562
  // copy as is, then adjust the glyphs count
557
563
 
558
564
  TableEntry* tableEntry = mTrueTypeInput.GetTableEntry("maxp");
565
+ if (!tableEntry) {
566
+ return PDFHummus::eFailure;
567
+ }
559
568
  LongFilePositionType startTableOffset;
560
569
  OutputStreamTraits streamCopier(&mFontFileStream);
561
570
  LongFilePositionType endOfStream;
@@ -602,6 +611,9 @@ EStatusCode TrueTypeEmbeddedFontWriter::WriteGlyf(const UIntVector& inSubsetGlyp
602
611
  // while at it...update the locaTable
603
612
 
604
613
  TableEntry* tableEntry = mTrueTypeInput.GetTableEntry("glyf");
614
+ if (!tableEntry) {
615
+ return PDFHummus::eFailure;
616
+ }
605
617
  LongFilePositionType startTableOffset = mFontFileStream.GetCurrentPosition();
606
618
  UIntVector::const_iterator it = inSubsetGlyphIDs.begin();
607
619
  OutputStreamTraits streamCopier(&mFontFileStream);
@@ -706,6 +718,9 @@ EStatusCode TrueTypeEmbeddedFontWriter::CreateTableCopy(const char* inTableName,
706
718
  // copy as is, no adjustments required
707
719
 
708
720
  TableEntry* tableEntry = mTrueTypeInput.GetTableEntry(inTableName);
721
+ if (!tableEntry) {
722
+ return PDFHummus::eFailure;
723
+ }
709
724
  LongFilePositionType startTableOffset;
710
725
  OutputStreamTraits streamCopier(&mFontFileStream);
711
726
  LongFilePositionType endOfStream;