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 <haroldo.santos@gmail.com>
This commit is contained in:
Haroldo Santos authored and Carlos R. Mafra committed 2026-10-21 12:20:34 +01:00
1 parent c0104d56bf
commit 0dd8b6a099
1 file changed
+2
+2
View File
@@ -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;