Skip to content

Commit ba05046

Browse files
committed
PDFBOX-4892: avoid ClassCastException, as suggested by valerybokov; remove unneeded code
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1889552 13f79535-47bb-0310-9956-ffa450edef68
1 parent e644c29 commit ba05046

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,10 @@ private void validateICCProfile(COSBase destOutputProfile,
272272
{
273273
try
274274
{
275-
if (destOutputProfile == null)
276-
{
277-
return;
278-
}
279-
280-
COSBase localDestOutputProfile = destOutputProfile;
281275
// destOutputProfile should be an instance of COSObject because of this is a object reference
282-
if (localDestOutputProfile instanceof COSObject)
276+
if (destOutputProfile instanceof COSObject)
283277
{
284-
if (mapDestOutputProfile.containsKey(new COSObjectKey((COSObject) localDestOutputProfile)))
278+
if (mapDestOutputProfile.containsKey(new COSObjectKey((COSObject) destOutputProfile)))
285279
{
286280
// the profile is already checked. continue
287281
return;
@@ -294,13 +288,18 @@ else if (!mapDestOutputProfile.isEmpty())
294288
return;
295289
}
296290
// else the profile will be kept in the mapDestOutputProfile if it is valid
297-
298-
localDestOutputProfile = ((COSObject) localDestOutputProfile).getObject();
291+
}
292+
else
293+
{
294+
addValidationError(ctx, new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,
295+
"OutputIntent object should be a reference: " + destOutputProfile));
296+
return;
299297
}
300298

301299
// keep reference to avoid multiple profile definition
302300
mapDestOutputProfile.put(new COSObjectKey((COSObject) destOutputProfile), true);
303301

302+
COSBase localDestOutputProfile = ((COSObject) destOutputProfile).getObject();
304303
if (!(localDestOutputProfile instanceof COSStream))
305304
{
306305
addValidationError(ctx, new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,

0 commit comments

Comments
 (0)