diff --git a/src/r_data.c b/src/r_data.c
index 2c10e0143f49221e982428a89bef5e9eebb7273a..485de3c40c60162f4a9025abf805c15362fe2541 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -2744,7 +2744,7 @@ static png_bytep *PNG_Read(UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, I
 	png_read_image(png_ptr, row_pointers);
 
 	// Read grAB chunk
-	if (topoffset || leftoffset)
+	if ((topoffset || leftoffset) && (chunk.data != NULL))
 	{
 		INT32 *offsets = (INT32 *)chunk.data;