Integrated: JDK-8344907 : NullPointerException in Win32ShellFolder2.getSystemIcon when "icon" is null

Harshitha Onkar honkar at openjdk.org
Thu Jan 9 18:25:44 UTC 2025


On Mon, 16 Dec 2024 23:49:58 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

> Win32ShellFolder2.getSystemIcon() can result in NPE if icon is null. Sanity null checks have been added.
> 
> 
> long hIcon = getSystemIcon(iconType.getIconID()); //Can return null
> Image icon = makeIcon(hIcon); // returns null if the condition (hIcon != 0L && hIcon != -1L) is false
> if (LARGE_ICON_SIZE != icon.getWidth(null)) { // NullPointerException -- icon is null
> 
> 
> Occurs when Windows is unable to provide a system icon and the code assumes an icon will **always** be returned, but the Windows API makes no such guarantee.
> 
> getSystemIcon calls LoadIcon (User32.dll). This can return null.
> https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadicona

This pull request has now been integrated.

Changeset: 9f3c5f95
Author:    Harshitha Onkar <honkar at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/9f3c5f95361c75d2b4d9e083901ce5a0ebf355e0
Stats:     20 lines in 1 file changed: 10 ins; 5 del; 5 mod

8344907: NullPointerException in Win32ShellFolder2.getSystemIcon when "icon" is null

Reviewed-by: aivanov, kizune

-------------

PR: https://git.openjdk.org/jdk/pull/22776


More information about the client-libs-dev mailing list