Fix crashes during processing of large animated WebPs

This commit is contained in:
DarthSim
2023-09-08 17:07:09 +03:00
parent b4ee0ceb3e
commit 756958d2ca
5 changed files with 27 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
- Fix parsing of HEIF files with large boxes.
- Fix wrong colors when the source image has a linear colorspace.
- Fix wrong colors or opacity when the source image is a TIFF with a float sample format.
- Fix crashes during processing of large animated WebPs.
- (pro) Fix generating thumbnails for WebM videos with transparency.
## [3.19.0] - 2023-08-21

View File

@@ -155,6 +155,12 @@ func transformAnimated(ctx context.Context, img *vips.Image, po *options.Process
}
}()
// Splitting and joining back large WebPs may cause segfault.
// Caching page region cures this
if err = img.LineCache(frameHeight); err != nil {
return err
}
for i := 0; i < framesCount; i++ {
frame := new(vips.Image)

View File

@@ -714,6 +714,13 @@ vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, int l
return res;
}
int
vips_linecache_seq(VipsImage *in, VipsImage **out, int tile_height)
{
return vips_linecache(in, out, "tile_height", tile_height, "access", VIPS_ACCESS_SEQUENTIAL,
NULL);
}
int
vips_arrayjoin_go(VipsImage **in, VipsImage **out, int n) {
return vips_arrayjoin(in, out, n, "across", 1, NULL);

View File

@@ -406,6 +406,17 @@ func (img *Image) Clear() {
}
}
func (img *Image) LineCache(lines int) error {
var tmp *C.VipsImage
if C.vips_linecache_seq(img.VipsImage, &tmp, C.int(lines)) != 0 {
return Error()
}
C.swap_and_clear(&img.VipsImage, tmp)
return nil
}
func (img *Image) Arrayjoin(in []*Image) error {
var tmp *C.VipsImage

View File

@@ -76,6 +76,8 @@ int vips_embed_go(VipsImage *in, VipsImage **out, int x, int y, int width, int h
int vips_apply_watermark(VipsImage *in, VipsImage *watermark, VipsImage **out, int left, int top,
double opacity);
int vips_linecache_seq(VipsImage *in, VipsImage **out, int tile_height);
int vips_arrayjoin_go(VipsImage **in, VipsImage **out, int n);
int vips_strip(VipsImage *in, VipsImage **out, int keep_exif_copyright);