Merge pull request #8006 from Yay295/patch-4

Extract band count check
This commit is contained in:
Hugo van Kemenade 2024-04-24 07:25:37 +03:00 committed by GitHub
commit 98e3f591d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,11 +24,11 @@ ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
ImagingSectionCookie cookie;
/* Assume there's enough data in the buffer */
if (!im) {
if (!im || im->bands != 3) {
return (Imaging)ImagingError_ModeError();
}
if (strcmp(mode, "L") == 0 && im->bands == 3) {
if (strcmp(mode, "L") == 0) {
imOut = ImagingNewDirty("L", im->xsize, im->ysize);
if (!imOut) {
return NULL;
@ -47,7 +47,7 @@ ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
}
ImagingSectionLeave(&cookie);
} else if (strlen(mode) == 3 && im->bands == 3) {
} else if (strlen(mode) == 3) {
imOut = ImagingNewDirty(mode, im->xsize, im->ysize);
if (!imOut) {
return NULL;