diff --git a/CHANGES.rst b/CHANGES.rst index afe5cb1b9..c812a9e00 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -38,7 +38,7 @@ Changelog (Pillow) [AbdealiJK] - Binary Tiff Metadata/ICC profile. #1988 - [wiredfool] + [wiredfool] - Ignore large text blocks in PNG if LOAD_TRUNCATED_IMAGES is enabled #1970 [homm] diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index 54db248a6..b680072ac 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -417,7 +417,7 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options: (it is set to 9 regardless of a value passed). **icc_profile** - The ICC Profile to include in the saved file. + The ICC Profile to include in the saved file. **bits (experimental)** For ``P`` images, this option controls how many bits to store. If omitted, diff --git a/docs/handbook/writing-your-own-file-decoder.rst b/docs/handbook/writing-your-own-file-decoder.rst index c8be936af..1affdc40d 100644 --- a/docs/handbook/writing-your-own-file-decoder.rst +++ b/docs/handbook/writing-your-own-file-decoder.rst @@ -322,7 +322,7 @@ There are 3 stages in a file decoder's lifetime: Setup ------ +----- The current conventions are that the decoder setup function is named ``PyImaging_[Decodername]DecoderNew`` and defined in ``decode.c``. The @@ -334,15 +334,15 @@ The setup function needs to call ``PyImaging_DecoderNew`` and at the very least, set the ``decode`` function pointer. The fields of interest in this object are: -**decode** +**decode** Function pointer to the decode function, which has access to ``im``, ``state``, and the buffer of data to be added to the image. -**cleanup** +**cleanup** Function pointer to the cleanup function, has access to ``state``. -**im** - The target image, will be set by Pillow. +**im** + The target image, will be set by Pillow. **state** An ImagingCodecStateInstance, will be set by Pillow. The **context** @@ -350,7 +350,7 @@ interest in this object are: any format specific state or options. **handles_eof** - UNDONE, set if your code handles EOF errors. + UNDONE, set if your code handles EOF errors. **pulls_fd** **EXPERIMENTAL** -- **WARNING**, interface may change. If set to 1, @@ -380,9 +380,9 @@ call to the decoder will include the previous unconsumed tail. The decoder function will be called multiple times as the data is read from the file like object. -If an error occurs, set ``state->errcode`` and return -1. +If an error occurs, set ``state->errcode`` and return -1. -Return -1 on success, without setting the errcode. +Return -1 on success, without setting the errcode. Cleanup ------- diff --git a/docs/releasenotes/3.3.0.rst b/docs/releasenotes/3.3.0.rst index b8addfabd..544c7162e 100644 --- a/docs/releasenotes/3.3.0.rst +++ b/docs/releasenotes/3.3.0.rst @@ -42,7 +42,7 @@ Rotation Rotation for angles divisible by 90 degrees now always uses transposition. This greatly improve both quality and performance in this cases. -Also, the bug with wrong image size calculation when rotating by 90 degrees +Also, the bug with wrong image size calculation when rotating by 90 degrees was fixed. diff --git a/libImaging/Draw.c b/libImaging/Draw.c index ef3f54dc0..ca26282be 100644 --- a/libImaging/Draw.c +++ b/libImaging/Draw.c @@ -463,7 +463,7 @@ polygon_generic(Imaging im, int n, Edge *e, int ink, int eofill, } /* Process the edge table with a scan line searching for intersections */ - /* malloc check ok, using calloc */ + /* malloc check ok, using calloc */ xx = calloc(edge_count * 2, sizeof(float)); if (!xx) { free(edge_table); diff --git a/libImaging/Jpeg2KDecode.c b/libImaging/Jpeg2KDecode.c index 250860009..5afa4a23d 100644 --- a/libImaging/Jpeg2KDecode.c +++ b/libImaging/Jpeg2KDecode.c @@ -776,7 +776,7 @@ ImagingJpeg2KDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) state->errcode = IMAGING_CODEC_BROKEN; state->state = J2K_STATE_FAILED; return -1; - } + } if (state->state == J2K_STATE_DONE || state->state == J2K_STATE_FAILED) return -1; diff --git a/libImaging/Quant.c b/libImaging/Quant.c index f041451be..7d24e7812 100644 --- a/libImaging/Quant.c +++ b/libImaging/Quant.c @@ -971,7 +971,7 @@ compute_palette_from_median_cut( avg[i]=NULL; } for(i=0;i<3;i++) { - /* malloc check ok, using calloc */ + /* malloc check ok, using calloc */ if (!(avg[i]=calloc(nPaletteEntries, sizeof(uint32_t)))) { for(i=0;i<3;i++) { if (avg[i]) free (avg[i]); diff --git a/libImaging/QuantHeap.c b/libImaging/QuantHeap.c index 2a4a5adc0..d6b920787 100644 --- a/libImaging/QuantHeap.c +++ b/libImaging/QuantHeap.c @@ -51,7 +51,7 @@ static int _heap_grow(Heap *h,int newsize) { if (newsize > INT_MAX / sizeof(void *)){ return 0; } - /* malloc check ok, using calloc for overflow, also checking + /* malloc check ok, using calloc for overflow, also checking above due to memcpy below*/ newheap=calloc(newsize, sizeof(void *)); if (!newheap) return 0; @@ -144,9 +144,9 @@ Heap *ImagingQuantHeapNew(HeapCmpFunc cf) { h->heapsize=INITIAL_SIZE; /* malloc check ok, using calloc for overflow */ h->heap=calloc(h->heapsize, sizeof(void *)); - if (!h->heap) { - free(h); - return NULL; + if (!h->heap) { + free(h); + return NULL; } h->heapcount=0; h->cf=cf; diff --git a/libImaging/RankFilter.c b/libImaging/RankFilter.c index 9294530c8..c0cb364c9 100644 --- a/libImaging/RankFilter.c +++ b/libImaging/RankFilter.c @@ -61,7 +61,7 @@ ImagingRankFilter(Imaging im, int size, int rank) return (Imaging) ImagingError_ValueError("bad filter size"); /* malloc check ok, for overflow in the define below */ - if (size > INT_MAX / size || + if (size > INT_MAX / size || size > INT_MAX / (size * sizeof(FLOAT32))) { return (Imaging) ImagingError_ValueError("filter size too large"); } diff --git a/libImaging/codec_fd.c b/libImaging/codec_fd.c index 33954ece0..d6590629c 100644 --- a/libImaging/codec_fd.c +++ b/libImaging/codec_fd.c @@ -3,7 +3,7 @@ #include "../py3.h" -Py_ssize_t +Py_ssize_t _imaging_read_pyFd(PyObject *fd, char* dest, Py_ssize_t bytes) { /* dest should be a buffer bytes long, returns length of read @@ -17,7 +17,7 @@ _imaging_read_pyFd(PyObject *fd, char* dest, Py_ssize_t bytes) result = PyObject_CallMethod(fd, "read", "n", bytes); bytes_result = PyBytes_AsStringAndSize(result, &buffer, &length); - if (bytes_result == -1) { + if (bytes_result == -1) { goto err; } @@ -25,18 +25,18 @@ _imaging_read_pyFd(PyObject *fd, char* dest, Py_ssize_t bytes) goto err; } - memcpy(dest, buffer, length); + memcpy(dest, buffer, length); Py_DECREF(result); return length; err: Py_DECREF(result); - return -1; + return -1; } -Py_ssize_t +Py_ssize_t _imaging_write_pyFd(PyObject *fd, char* src, Py_ssize_t bytes) { @@ -60,7 +60,7 @@ _imaging_seek_pyFd(PyObject *fd, Py_ssize_t offset, int whence) result = PyObject_CallMethod(fd, "seek", "ni", offset, whence); - Py_DECREF(result); + Py_DECREF(result); return 0; }