From 2313eb0d99ab8a3e6188b083adf528fe6b96bca7 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Fri, 11 Apr 2025 03:51:23 -0700 Subject: [PATCH] nv2a/gl: Use glReadnPixels to validate expected read size --- hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/common.c b/hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/common.c index f0c90df6ef..472c4c721d 100644 --- a/hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/common.c +++ b/hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/common.c @@ -46,7 +46,9 @@ void glo_readpixels(GLenum gl_format, GLenum gl_type, glPixelStorei(GL_PACK_ROW_LENGTH, stride / bytes_per_pixel); glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0, 0, width, height, gl_format, gl_type, data); + const size_t max_read_size = stride * height; + glReadnPixels(0, 0, width, height, gl_format, gl_type, max_read_size, data); + assert(glGetError() == GL_NO_ERROR); if (vflip) { GLubyte *b = (GLubyte *) data;