mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Avoid borrow panic when Path2D.addPath is called with self (#36847)
Fixes: #36842 Signed-off-by: Taym <haddadi.taym@gmail.com>
This commit is contained in:
parent
3936b1d22b
commit
7ea5951e34
3 changed files with 20 additions and 2 deletions
|
@ -65,8 +65,14 @@ impl Path2DMethods<crate::DomTypeHolder> for Path2D {
|
|||
/// <https://html.spec.whatwg.org/multipage/#dom-path2d-addpath>
|
||||
fn AddPath(&self, other: &Path2D) {
|
||||
// Step 7. Add all the subpaths in c to a.
|
||||
let mut dest = self.path.borrow_mut();
|
||||
dest.extend(other.path.borrow().iter().copied());
|
||||
if std::ptr::eq(&self.path, &other.path) {
|
||||
// Note: this is not part of the spec, but it is a workaround to
|
||||
// avoids borrow conflict when path is same as other.path
|
||||
self.path.borrow_mut().extend_from_within(..);
|
||||
} else {
|
||||
let mut dest = self.path.borrow_mut();
|
||||
dest.extend(other.path.borrow().iter().copied());
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-context-2d-closepath>
|
||||
|
|
7
tests/wpt/mozilla/meta/MANIFEST.json
vendored
7
tests/wpt/mozilla/meta/MANIFEST.json
vendored
|
@ -53,6 +53,13 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"path2D_addPath-crash.html": [
|
||||
"f913e6baf8340886c58f99609755ae061bf64f12",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"test-wait-crash.html": [
|
||||
"2419da6af0c278a17b9ff974d4418f9e386ef3e0",
|
||||
[
|
||||
|
|
5
tests/wpt/mozilla/tests/mozilla/path2D_addPath-crash.html
vendored
Normal file
5
tests/wpt/mozilla/tests/mozilla/path2D_addPath-crash.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<script>
|
||||
let path2D = new Path2D();
|
||||
path2D.addPath(path2D);
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue