mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-08 08:10:30 -10:00
gl1/gl2/gl3: an overlay page's last image is in bounds, and name 0 is not art
The overlay id check read `image > gl->overlays`, one past the page's last entry, and the tex_geom setters had no check at all - a write through a NULL coordinate array before a page is loaded, or into the neighbouring region of the block the three coordinate arrays share. gl3_render_overlay() also drew entries whose texture name was 0. That is black on a core context, but a GLES driver may sample whatever the unit last held, which on the alpha blend pipeline's unit is the content texture - the page's art then shows the core image.
This commit is contained in:
1 parent
c7be399ec9
commit
7661ab06e7
3 files changed
+25
-9
No files matched your search
+6
-3
@@ -1254,10 +1254,10 @@ static void gl1_overlay_vertex_geom(void *data,
|
||||
GLfloat *vertex = NULL;
|
||||
gl1_t *gl = (gl1_t*)data;
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !gl->overlay_vertex_coord)
|
||||
return;
|
||||
|
||||
if (image > gl->overlays)
|
||||
if (image >= gl->overlays)
|
||||
{
|
||||
RARCH_ERR("[GL1] Invalid overlay id: %u.\n", image);
|
||||
return;
|
||||
@@ -1287,7 +1287,10 @@ static void gl1_overlay_tex_geom(void *data,
|
||||
GLfloat *tex = NULL;
|
||||
gl1_t *gl = (gl1_t*)data;
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !gl->overlay_tex_coord)
|
||||
return;
|
||||
|
||||
if (image >= gl->overlays)
|
||||
return;
|
||||
|
||||
tex = (GLfloat*)&gl->overlay_tex_coord[image * 8];
|
||||
|
||||
+6
-3
@@ -2993,10 +2993,10 @@ static void gl2_overlay_vertex_geom(void *data,
|
||||
GLfloat *vertex = NULL;
|
||||
gl2_t *gl = (gl2_t*)data;
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !gl->overlay_vertex_coord)
|
||||
return;
|
||||
|
||||
if (image > gl->overlays)
|
||||
if (image >= gl->overlays)
|
||||
{
|
||||
RARCH_ERR("[GL] Invalid overlay id: %u\n", image);
|
||||
return;
|
||||
@@ -3026,7 +3026,10 @@ static void gl2_overlay_tex_geom(void *data,
|
||||
GLfloat *tex = NULL;
|
||||
gl2_t *gl = (gl2_t*)data;
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !gl->overlay_tex_coord)
|
||||
return;
|
||||
|
||||
if (image >= gl->overlays)
|
||||
return;
|
||||
|
||||
tex = (GLfloat*)&gl->overlay_tex_coord[image * 8];
|
||||
|
||||
+13
-3
@@ -1830,10 +1830,10 @@ static void gl3_overlay_vertex_geom(void *data,
|
||||
GLfloat *vertex = NULL;
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !gl->overlay_vertex_coord)
|
||||
return;
|
||||
|
||||
if (image > gl->overlays)
|
||||
if (image >= gl->overlays)
|
||||
return;
|
||||
|
||||
vertex = (GLfloat*)&gl->overlay_vertex_coord[image * 8];
|
||||
@@ -1860,7 +1860,10 @@ static void gl3_overlay_tex_geom(void *data,
|
||||
GLfloat *tex = NULL;
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
|
||||
if (!gl)
|
||||
if (!gl || !gl->overlay_tex_coord)
|
||||
return;
|
||||
|
||||
if (image >= gl->overlays)
|
||||
return;
|
||||
|
||||
tex = (GLfloat*)&gl->overlay_tex_coord[image * 8];
|
||||
@@ -1880,6 +1883,9 @@ static void gl3_render_overlay(gl3_t *gl,
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!gl->overlay_tex || !gl->overlays)
|
||||
return;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
@@ -1915,6 +1921,10 @@ static void gl3_render_overlay(gl3_t *gl,
|
||||
|
||||
for (i = 0; i < gl->overlays; i++)
|
||||
{
|
||||
/* Name 0 is black only on a core context; a GLES driver may
|
||||
* sample whatever the unit last held. */
|
||||
if (!gl->overlay_tex[i])
|
||||
continue;
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, gl->overlay_tex[i]);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, (GLint)(4 * i), 4);
|
||||
|
||||
Reference in new issue
Block a user