Skip to content

Commit 51ba231

Browse files
committed
PDFBOX-4892: remove redundant null check for loops, as suggested by valerybokov
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1889584 13f79535-47bb-0310-9956-ffa450edef68
1 parent bb61e87 commit 51ba231

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

preflight/src/main/java/org/apache/pdfbox/preflight/graphic/ICCProfileWrapper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ private static ICCProfileWrapper searchFirstICCProfile(PreflightContext context)
123123
PDDocumentCatalog catalog = document.getDocumentCatalog();
124124
COSArray outputIntents = catalog.getCOSObject().getCOSArray(COSName.OUTPUT_INTENTS);
125125

126-
for (int i = 0; outputIntents != null && i < outputIntents.size(); ++i)
126+
if (outputIntents == null)
127+
{
128+
return null;
129+
}
130+
for (int i = 0; i < outputIntents.size(); ++i)
127131
{
128132
COSDictionary outputIntentDict = (COSDictionary) outputIntents.getObject(i);
129133
COSBase destOutputProfile = outputIntentDict

preflight/src/main/java/org/apache/pdfbox/preflight/process/CatalogValidationProcess.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ private void validateOutputIntent(PreflightContext ctx) throws ValidationExcepti
192192
{
193193
COSArray outputIntents = catalog.getCOSObject().getCOSArray(COSName.OUTPUT_INTENTS);
194194
Map<COSObjectKey, Boolean> tmpDestOutputProfile = new HashMap<>();
195-
for (int i = 0; outputIntents != null && i < outputIntents.size(); ++i)
195+
if (outputIntents == null)
196+
{
197+
return;
198+
}
199+
for (int i = 0; i < outputIntents.size(); ++i)
196200
{
197201
COSDictionary outputIntentDict = (COSDictionary) outputIntents.getObject(i);
198202

0 commit comments

Comments
 (0)