fix: harden generate image mode validation
This commit is contained in:
parent
64b63d86bc
commit
32a9024938
@ -74,12 +74,12 @@ class GenerateImage extends Operation {
|
||||
Bits: 1 / 8,
|
||||
};
|
||||
|
||||
const bytesPerPixel = bytePerPixelMap[mode];
|
||||
|
||||
if (bytesPerPixel === undefined) {
|
||||
if (!Object.hasOwn(bytePerPixelMap, mode)) {
|
||||
throw new OperationError(`Unsupported Mode: (${mode})`);
|
||||
}
|
||||
|
||||
const bytesPerPixel = bytePerPixelMap[mode];
|
||||
|
||||
if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
|
||||
throw new OperationError(
|
||||
`Number of bytes is not a divisor of ${bytesPerPixel}`,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user