From 0dd8b6a099ac7c8b0980c8d1d957134ae8df8632 Mon Sep 17 00:00:00 2001 From: Haroldo Santos Date: Sat, 10 Oct 2026 18:04:42 -0400 Subject: [PATCH] wrlib: check RCreateImage() result in RMakeTiledImage() When the requested size is larger than the tile, RMakeTiledImage() creates a new image with RCreateImage() and immediately writes to image->data. RCreateImage() returns NULL when the allocation fails or when the dimensions exceed its limit (20000 pixels), so a very large background texture, or memory pressure, makes the caller crash instead of getting an error. The other branches of this function already return NULL on failure (RCloneImage() and RGetSubImage()), and the callers handle a NULL result, so return NULL here as well. Signed-off-by: Haroldo Santos --- wrlib/raster.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wrlib/raster.c b/wrlib/raster.c index 48c28704..3c7d988d 100644 --- a/wrlib/raster.c +++ b/wrlib/raster.c @@ -578,6 +578,8 @@ RImage *RMakeTiledImage(RImage * tile, unsigned width, unsigned height) int has_alpha = HAS_ALPHA(tile); image = RCreateImage(width, height, has_alpha); + if (!image) + return NULL; d = image->data; s = tile->data;