Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ _resize(ImagingObject *self, PyObject *args) {

imOut = ImagingNewDirty(imIn->mode, xsize, ysize);

imOut = ImagingTransform(
ImagingTransform(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an error check here?

imOut, imIn, IMAGING_TRANSFORM_AFFINE, 0, 0, xsize, ysize, a, filter, 1
);
} else {
Expand Down Expand Up @@ -2167,13 +2167,13 @@ _transform(ImagingObject *self, PyObject *args) {
return NULL;
}

imOut = ImagingTransform(
int error = ImagingTransform(
self->image, imagep->image, method, x0, y0, x1, y1, a, filter, fill
);

free(a);

if (!imOut) {
if (error) {
return NULL;
}

Expand Down
36 changes: 21 additions & 15 deletions src/libImaging/Geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ getfilter(Imaging im, int filterid) {

/* transformation engines */

Imaging
int
ImagingGenericTransform(
Imaging imOut,
Imaging imIn,
Expand All @@ -801,12 +801,14 @@ ImagingGenericTransform(
double xx, yy;

if (!imOut || !imIn || imIn->mode != imOut->mode) {
return (Imaging)ImagingError_ModeError();
ImagingError_ModeError();
return -1;
}

ImagingTransformFilter filter = getfilter(imIn, filterid);
if (!filter) {
return (Imaging)ImagingError_ValueError("bad filter number");
ImagingError_ValueError("bad filter number");
return -1;
}

ImagingCopyPalette(imOut, imIn);
Expand Down Expand Up @@ -841,10 +843,10 @@ ImagingGenericTransform(

ImagingSectionLeave(&cookie);

return imOut;
return 0;
}

static Imaging
static int
ImagingScaleAffine(
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1, double a[6], int fill
) {
Expand All @@ -858,7 +860,8 @@ ImagingScaleAffine(
int *xintab;

if (!imOut || !imIn || imIn->mode != imOut->mode) {
return (Imaging)ImagingError_ModeError();
ImagingError_ModeError();
return -1;
}

ImagingCopyPalette(imOut, imIn);
Expand All @@ -883,7 +886,8 @@ ImagingScaleAffine(
xintab = (int *)calloc(out_xsize, sizeof(int));
if (!xintab) {
ImagingDelete(imOut);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... whose responsibility it is to delete imOut? 🤔 The above error returns do not delete it, this does?

return (Imaging)ImagingError_MemoryError();
ImagingError_MemoryError();
return -1;
}

xo = a[2] + a[0] * 0.5;
Expand Down Expand Up @@ -936,7 +940,7 @@ ImagingScaleAffine(

free(xintab);

return imOut;
return 0;
}

static inline int
Expand All @@ -947,7 +951,7 @@ check_fixed(double a[6], int x, int y) {
);
}

static inline Imaging
static inline int
affine_fixed(
Imaging imOut,
Imaging imIn,
Expand Down Expand Up @@ -1022,10 +1026,10 @@ affine_fixed(

#undef AFFINE_TRANSFORM_FIXED

return imOut;
return 0;
}

Imaging
int
ImagingTransformAffine(
Imaging imOut,
Imaging imIn,
Expand All @@ -1048,7 +1052,8 @@ ImagingTransformAffine(
double xo, yo;

if (!imOut || !imIn || imIn->mode != imOut->mode) {
return (Imaging)ImagingError_ModeError();
ImagingError_ModeError();
return -1;
}

if (filterid || imIn->type == IMAGING_TYPE_I16) {
Expand Down Expand Up @@ -1131,10 +1136,10 @@ ImagingTransformAffine(

#undef AFFINE_TRANSFORM

return imOut;
return 0;
}

Imaging
int
ImagingTransform(
Imaging imOut,
Imaging imIn,
Expand Down Expand Up @@ -1162,7 +1167,8 @@ ImagingTransform(
transform = quad_transform;
break;
default:
return (Imaging)ImagingError_ValueError("bad transform method");
ImagingError_ValueError("bad transform method");
return -1;
}

return ImagingGenericTransform(
Expand Down
2 changes: 1 addition & 1 deletion src/libImaging/Imaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ extern Imaging
ImagingResample(Imaging imIn, int xsize, int ysize, int filter, float box[4]);
extern Imaging
ImagingReduce(Imaging imIn, int xscale, int yscale, int box[4]);
extern Imaging
extern int
ImagingTransform(
Imaging imOut,
Imaging imIn,
Expand Down
Loading