On Mon, 3 Aug 2026 07:19:21 GMT, Matthias Baesken <[email protected]> wrote:
>> src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp line 4268: >> >>> 4266: } >>> 4267: >>> 4268: DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames); >> >> If we are going to do the check on alloc, we should also do the check on >> lock, like done for pDevMode at line 4237. > > That's a good point! > The documentation says > https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globallock > " If the function succeeds, the return value is a pointer to the first byte > of the memory block. If the function fails, the return value is NULL." > > So it can fail and better should be checked ! Unfortunately we have quite a few code locations where we miss the NULL-check of the return value https://github.com/openjdk/jdk/blob/81c9ea0682c54beb82f6259104f266bbc57c2fd6/src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp#L916 https://github.com/openjdk/jdk/blob/81c9ea0682c54beb82f6259104f266bbc57c2fd6/src/java.desktop/windows/native/libawt/windows/awt_Clipboard.cpp#L247 https://github.com/openjdk/jdk/blob/81c9ea0682c54beb82f6259104f266bbc57c2fd6/src/java.desktop/windows/native/libawt/windows/awt_DataTransferer.cpp#L272 Should those be addressed to (maybe in another PR?) or is it just extremely unlikely that the call fails? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32151#discussion_r3702042440
