File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1624,31 +1624,31 @@ class ImageType {
16241624 * @returns {boolean }
16251625 */
16261626 static isPNG ( view ) {
1627- return view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . PNG ;
1627+ return view . byteLength >= 4 && view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . PNG ;
16281628 }
16291629
16301630 /**
16311631 * @param {DataView } view
16321632 * @returns {boolean }
16331633 */
16341634 static isJPEG ( view ) {
1635- return ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . JPEG ;
1635+ return view . byteLength >= 4 && ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . JPEG ;
16361636 }
16371637
16381638 /**
16391639 * @param {DataView } view
16401640 * @returns {boolean }
16411641 */
16421642 static isTIFF ( view ) {
1643- return view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . TIFF ;
1643+ return view . byteLength >= 4 && view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . TIFF ;
16441644 }
16451645
16461646 /**
16471647 * @param {DataView } view
16481648 * @returns {boolean }
16491649 */
16501650 static isGIF ( view ) {
1651- return ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . GIF ;
1651+ return view . byteLength >= 4 && ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . GIF ;
16521652 }
16531653}
16541654
You can’t perform that action at this time.
0 commit comments