Skip to content

Commit

Permalink
Merge pull request #8006 from Yay295/patch-4
Browse files Browse the repository at this point in the history
Extract band count check
  • Loading branch information
hugovk committed Apr 24, 2024
2 parents 2adeb7a + eee53ba commit 98e3f59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libImaging/Matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 98e3f59

Please sign in to comment.