Skip to content

Commit

Permalink
Merge pull request #747 from jhult/master
Browse files Browse the repository at this point in the history
Call `Native.toString()` in `#getFileName()` & `#getAlternateFileName()`
  • Loading branch information
matthiasblaesing authored Dec 31, 2016
2 parents 981510e + 108520e commit 58fef22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
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

0 comments on commit 58fef22

Please sign in to comment.