diff options
author | Gae24 <96017547+Gae24@users.noreply.github.com> | 2025-02-27 20:28:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-27 19:28:35 +0000 |
commit | 900655fbc7dd20a6aae4f909fcce44a6f967fb1e (patch) | |
tree | be1360f3504a1ee9bc54cc3f6be9ed11d79811f0 /components/script/dom/datatransferitem.rs | |
parent | 8a3f62933bd6ccc4579162af13b5cbc6fa11db96 (diff) | |
download | servo-900655fbc7dd20a6aae4f909fcce44a6f967fb1e.tar.gz servo-900655fbc7dd20a6aae4f909fcce44a6f967fb1e.zip |
script: Avoid double borrow crash in `DataTransferItem` (#35699)
* avoid double borrow inside GetAsString
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
* added crashtest
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
---------
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Diffstat (limited to 'components/script/dom/datatransferitem.rs')
-rw-r--r-- | components/script/dom/datatransferitem.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/components/script/dom/datatransferitem.rs b/components/script/dom/datatransferitem.rs index d4888d2f91c..db25b62178e 100644 --- a/components/script/dom/datatransferitem.rs +++ b/components/script/dom/datatransferitem.rs @@ -123,7 +123,8 @@ impl DataTransferItemMethods<crate::DomTypeHolder> for DataTransferItem { .task_manager() .dom_manipulation_task_source() .queue(task!(invoke_callback: move || { - if let Some(index) = this.root().pending_callbacks.borrow().iter().position(|val| val.id == id) { + let maybe_index = this.root().pending_callbacks.borrow().iter().position(|val| val.id == id); + if let Some(index) = maybe_index { let callback = this.root().pending_callbacks.borrow_mut().swap_remove(index).callback; let _ = callback.Call__(DOMString::from(string), ExceptionHandling::Report); } |