Fix NullPointerExceprion when getGID() was called on null#688
Fix NullPointerExceprion when getGID() was called on null#688MaximPlusov merged 2 commits intointegrationfrom
Conversation
WalkthroughAdded null checks for the CmapParser in TrueTypeFontProgram: getWidth and getWidthSymbolic now return 0 when the parser is null; otherwise they obtain a glyph ID from the CmapParser and use getWidthWithCheck(gid). Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/org/verapdf/pd/font/truetype/TrueTypeFontProgram.java (1)
227-228: Apply the same null check here to prevent NPE.This code has the same NPE risk that was fixed in the
getWidthmethod above. ThegetCmapParser()call should be null-checked before invokinggetGID().Apply this diff to add consistent null handling:
- gid = this.parser.getCmapParser().getGID(code); - return getWidthWithCheck(gid); + if (this.parser.getCmapParser() == null) { + return 0; + } + gid = this.parser.getCmapParser().getGID(code); + return getWidthWithCheck(gid);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/org/verapdf/pd/font/truetype/TrueTypeFontProgram.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.