From 7d7c46cbc96afa0f926e7d3dddadd65e24de0f09 Mon Sep 17 00:00:00 2001 From: Isaiah Inuwa Date: Mon, 23 Sep 2019 22:27:30 -0500 Subject: [PATCH] Add check for empty data on ImageData constructor. --- components/script/dom/imagedata.rs | 2 +- .../2d.imageData.object.ctor.array.bounds.html.ini | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.object.ctor.array.bounds.html.ini diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index 52851fdce36..6eb5bfd3489 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -76,7 +76,7 @@ impl ImageData { })?; let byte_len = array.as_slice().len() as u32; - if byte_len % 4 != 0 { + if byte_len % 4 != 0 || byte_len == 0 { return Err(Error::InvalidState); } diff --git a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.object.ctor.array.bounds.html.ini b/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.object.ctor.array.bounds.html.ini deleted file mode 100644 index a10bfc0c856..00000000000 --- a/tests/wpt/metadata/2dcontext/pixel-manipulation/2d.imageData.object.ctor.array.bounds.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[2d.imageData.object.ctor.array.bounds.html] - type: testharness - [ImageData has a usable constructor] - expected: FAIL -