mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 02:36:17 +03:00
Make the SGI code return -1 as an error flag, error in state
This commit is contained in:
parent
7e95c63fa7
commit
9a2c9f722f
|
@ -115,7 +115,8 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
||||||
/* size check */
|
/* size check */
|
||||||
if (im->xsize > INT_MAX / im->bands ||
|
if (im->xsize > INT_MAX / im->bands ||
|
||||||
im->ysize > INT_MAX / im->bands) {
|
im->ysize > INT_MAX / im->bands) {
|
||||||
return IMAGING_CODEC_MEMORY;
|
state->errcode = IMAGING_CODEC_MEMORY;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get all data from File descriptor */
|
/* Get all data from File descriptor */
|
||||||
|
@ -130,12 +131,14 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
||||||
Check here before we allocate any memory
|
Check here before we allocate any memory
|
||||||
*/
|
*/
|
||||||
if (c->bufsize < 8*c->tablen) {
|
if (c->bufsize < 8*c->tablen) {
|
||||||
return IMAGING_CODEC_MEMORY;
|
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = malloc(sizeof(UINT8) * c->bufsize);
|
ptr = malloc(sizeof(UINT8) * c->bufsize);
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
return IMAGING_CODEC_MEMORY;
|
state->errcode = IMAGING_CODEC_MEMORY;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
_imaging_seek_pyFd(state->fd, SGI_HEADER_SIZE, SEEK_SET);
|
_imaging_seek_pyFd(state->fd, SGI_HEADER_SIZE, SEEK_SET);
|
||||||
_imaging_read_pyFd(state->fd, (char*)ptr, c->bufsize);
|
_imaging_read_pyFd(state->fd, (char*)ptr, c->bufsize);
|
||||||
|
@ -185,7 +188,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
||||||
|
|
||||||
if (c->rleoffset + c->rlelength > c->bufsize) {
|
if (c->rleoffset + c->rlelength > c->bufsize) {
|
||||||
state->errcode = IMAGING_CODEC_OVERRUN;
|
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||||
return -1;
|
goto sgi_finish_decode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* row decompression */
|
/* row decompression */
|
||||||
|
@ -197,7 +200,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state,
|
||||||
}
|
}
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
state->errcode = IMAGING_CODEC_OVERRUN;
|
state->errcode = IMAGING_CODEC_OVERRUN;
|
||||||
return -1;
|
goto sgi_finish_decode;
|
||||||
} else if (status == 1) {
|
} else if (status == 1) {
|
||||||
goto sgi_finish_decode;
|
goto sgi_finish_decode;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +221,8 @@ sgi_finish_decode: ;
|
||||||
free(c->lengthtab);
|
free(c->lengthtab);
|
||||||
free(ptr);
|
free(ptr);
|
||||||
if (err != 0){
|
if (err != 0){
|
||||||
return err;
|
state->errcode=err;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return state->count - c->bufsize;
|
return state->count - c->bufsize;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user