Skip to content
Permalink
Browse files
6211198: ICC_Profile.getInstance(byte[]): IAE is not specified
Reviewed-by: prr, pbansal
  • Loading branch information
mrserb committed Feb 10, 2021
1 parent cc5691c commit 447db62762d7882cf5593155337b8c5acd99ecd1
@@ -758,12 +758,13 @@ protected void finalize () {

/**
* Constructs an {@code ICC_Profile} object corresponding to the data in a
* byte array. Throws an {@code IllegalArgumentException} if the data does
* not correspond to a valid ICC Profile.
* byte array.
*
* @param data the specified ICC Profile data
* @return an {@code ICC_Profile} object corresponding to the data in the
* specified {@code data} array
* @throws IllegalArgumentException If the byte array does not contain valid
* ICC Profile data
*/
public static ICC_Profile getInstance(byte[] data) {
ICC_Profile thisProfile;
@@ -957,12 +958,7 @@ public static ICC_Profile getInstance(String fileName) throws IOException {
* Profile data
*/
public static ICC_Profile getInstance(InputStream s) throws IOException {
byte[] profileData;
if ((profileData = getProfileDataFromStream(s)) == null) {
throw new IllegalArgumentException("Invalid ICC Profile Data");
}

return getInstance(profileData);
return getInstance(getProfileDataFromStream(s));
}


@@ -0,0 +1,42 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

import java.awt.color.ICC_Profile;

/**
* @test
* @bug 6211198
* @summary IllegalArgumentException in ICC_Profile.getInstance for broken data
*/
public final class GetInstanceBrokenData {

public static void main(String[] argv) {
byte b[] = {-21, -22, -23};
try {
ICC_Profile p = ICC_Profile.getInstance(b);
throw new RuntimeException("IllegalArgumentException is expected");
} catch (IllegalArgumentException ignored) {
// expected
}
}
}
@@ -27,7 +27,7 @@

/**
* @test
* @bug 4176618 7042594
* @bug 4176618 7042594 6211198
* @summary This interactive test verifies that passing null to
* ICC_ProfileRGB.getInstance() does not crash the VM.
* An IllegalArgumentException: Invalid ICC Profile Data should be

0 comments on commit 447db62

Please sign in to comment.