On Fri, 28 Jul 2023 08:23:35 GMT, Christoph Langer <[email protected]> wrote:
>> The function WideCharToMultiByte is used at a number of places of the JDK >> codebase for conversion purposes. >> Unfortunately, the function might fail because of various reasons, so the >> return value must be checked to avoid undefined behavior or even crashes. >> see >> https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte >> especially >> https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte#return-value >> >> At most places in the coding the return values are already checked, but some >> are missing. > > src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp line 3933: > >> 3931: JNU_ThrowByName(env, PRINTEREXCEPTION_STR, errStr); >> 3932: } else { >> 3933: JNU_ThrowByName(env, PRINTEREXCEPTION_STR, "Secondary error >> while OS message extraction"); > > better: secondary error during OS message extraction I borrowed it from here (other error handling of WideCharToMultiByte) jdk/src/java.base/windows/native/libjava/ProcessImpl_md.c 102 const char *errorMessage = "Secondary error while OS message extraction"; should I change both locations ? > src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Charset_Util.cpp > line 46: > >> 44: delete[] lpUTF8Str; >> 45: } >> 46: return NULL; > > better move `return NULL` into else block? Better remove the else block :-) ? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15015#discussion_r1277339373 PR Review Comment: https://git.openjdk.org/jdk/pull/15015#discussion_r1277340457
