Skip to content
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

Call Native.toString() in #getFileName() & #getAlternateFileName() #747

Merged
merged 1 commit into from
Dec 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Bug Fixes
* [#669](https://github.com/java-native-access/jna/pull/669): Ensure XSI-compliant strerror_r is used, to prevent corrupted error messages on linux - [@DavidKeller](https://github.com/DavidKeller).
* [#697](https://github.com/java-native-access/jna/issues/697): Ensure disposed memory is removed from Memory#allocatedMemory map - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#731](https://github.com/java-native-access/jna/issues/731): Require mingw-w64 instead of mingw as the alternative to the MSVC build - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#747](https://github.com/java-native-access/jna/issues/747): - Call `Native.toString()` in `#getFileName()` and `#getAlternateFileName()` in `c.s.j.p.win32.WinBase` instead of custom NUL terminator logic - [@jhult](https://github.com/jhult).

Release 4.2.1
=============
Expand Down
6 changes: 2 additions & 4 deletions contrib/platform/src/com/sun/jna/platform/win32/WinBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -817,16 +817,14 @@ public WIN32_FIND_DATA(int dwFileAttributes,
* @return String containing the file name
*/
public String getFileName() {
String actualFileName = new String(cFileName);
return actualFileName.substring(0, actualFileName.indexOf('\0'));
return Native.toString(cFileName);
}

/**
* @return String containing the alternate file name
*/
public String getAlternateFileName() {
String actualAlternateFileName = new String(cAlternateFileName);
return actualAlternateFileName.substring(0, actualAlternateFileName.indexOf('\0'));
return Native.toString(cAlternateFileName);
}
}

Expand Down