Skip to content

Commit 2909f18

Browse files
committed
Merge #114
2 parents 07e75a0 + c3c238e commit 2909f18

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/windows.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,22 @@ pub(super) fn open_browser_internal(
5454
return Err(Error::other("failed to get default browser"));
5555
}
5656

57+
let mut line_len = line_len as usize;
58+
59+
// If line_len wasn't updated, this might be a broken AssocQueryStringW() implementation in wine:
60+
// https://bugs.winehq.org/show_bug.cgi?id=59402
61+
// In that case, find the NUL terminator ourselves.
62+
if line_len == BUF_SIZE {
63+
if let Some(found_nul) = cmdline_u16.iter().position(|&c| c == 0) {
64+
trace!(
65+
"Broken AssocQueryStringW(), manually string length determined at {found_nul}"
66+
);
67+
line_len = found_nul + 1;
68+
}
69+
}
70+
5771
use std::os::windows::ffi::OsStringExt;
58-
std::ffi::OsString::from_wide(&cmdline_u16[..(line_len - 1) as usize])
72+
std::ffi::OsString::from_wide(&cmdline_u16[..(line_len - 1)])
5973
.into_string()
6074
.map_err(|_err| {
6175
Error::other(

0 commit comments

Comments
 (0)