RFR: JDK-8344907 : NullPointerException in Win32ShellFolder2.getSystemIcon when "icon" is null [v3]

Harshitha Onkar honkar at openjdk.org
Tue Jan 7 20:33:50 UTC 2025


> 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

Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:

  inverted hIcon condition

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22776/files
  - new: https://git.openjdk.org/jdk/pull/22776/files/2307a4a1..314d2ddf

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22776&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22776&range=01-02

  Stats: 26 lines in 1 file changed: 10 ins; 10 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/22776.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22776/head:pull/22776

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


More information about the client-libs-dev mailing list