File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1763,31 +1763,31 @@ class ImageType {
17631763 * @returns {boolean }
17641764 */
17651765 static isPNG ( view ) {
1766- return view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . PNG ;
1766+ return view . byteLength >= 4 && view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . PNG ;
17671767 }
17681768
17691769 /**
17701770 * @param {DataView } view
17711771 * @returns {boolean }
17721772 */
17731773 static isJPEG ( view ) {
1774- return ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . JPEG ;
1774+ return view . byteLength >= 4 && ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . JPEG ;
17751775 }
17761776
17771777 /**
17781778 * @param {DataView } view
17791779 * @returns {boolean }
17801780 */
17811781 static isTIFF ( view ) {
1782- return view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . TIFF ;
1782+ return view . byteLength >= 4 && view . getUint32 ( 0 , false ) === MAGIC_NUMBERS . TIFF ;
17831783 }
17841784
17851785 /**
17861786 * @param {DataView } view
17871787 * @returns {boolean }
17881788 */
17891789 static isGIF ( view ) {
1790- return ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . GIF ;
1790+ return view . byteLength >= 4 && ( view . getUint32 ( 0 , false ) >>> 8 ) === MAGIC_NUMBERS . GIF ;
17911791 }
17921792}
17931793
You can’t perform that action at this time.
0 commit comments