Skip to content
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
5 changes: 5 additions & 0 deletions .changes/fix-windows-drop-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
wry: patch
---

Fix `wry::DragDropEvent::Drop::paths` returns random data on Windows
6 changes: 2 additions & 4 deletions src/webview2/drag_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,11 @@ impl DragDropTarget {
// Previously, this was using a fixed size array of MAX_PATH length, but the
// Windows API allows longer paths under certain circumstances.
let character_count = DragQueryFileW(hdrop, i, None) as usize;
let str_len = character_count + 1;

// Fill path_buf with the null-terminated file name
let mut path_buf = Vec::with_capacity(str_len);
let str_len = character_count + 1;
let mut path_buf = vec![0; str_len];
DragQueryFileW(hdrop, i, Some(&mut path_buf));
path_buf.set_len(str_len);

callback(OsString::from_wide(&path_buf[0..character_count]).into());
}

Expand Down
Loading