-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8312612: handle WideCharToMultiByte return values #15015
Conversation
👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, two minor suggestions.
if (nb > 0) { | ||
JNU_ThrowByName(env, PRINTEREXCEPTION_STR, errStr); | ||
} else { | ||
JNU_ThrowByName(env, PRINTEREXCEPTION_STR, "Secondary error while OS message extraction"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better: secondary error during OS message extraction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ?
} else { | ||
delete[] lpUTF8Str; | ||
} | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better move return NULL
into else block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better remove the else block :-) ?
@MBaesken This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 38 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better.
Hi Christoph, thanks for the review. |
/integrate |
Going to push as commit d9559f9.
Your commit was automatically rebased without conflicts. |
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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15015/head:pull/15015
$ git checkout pull/15015
Update a local copy of the PR:
$ git checkout pull/15015
$ git pull https://git.openjdk.org/jdk.git pull/15015/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15015
View PR using the GUI difftool:
$ git pr show -t 15015
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15015.diff
Webrev
Link to Webrev Comment