Commit bfafa473 authored by HOU Qiming's avatar HOU Qiming Committed by Gerd Hoffmann
Browse files

ui/console: Precautionary glBindTexture and surface->texture validation in...


ui/console: Precautionary glBindTexture and surface->texture validation in surface_gl_update_texture

In a GVT-g setup with dmabuf and GTK GUI, the current 2D texture at
surface_gl_update_texture is not necessarily
surface->texture. Adding a glBindTexture fixes related crashes and
artifacts, and is generally more secure.

Signed-off-by: default avatarHOU Qiming <hqm03ster@gmail.com>
Tested-by: default avatarMarcel <Apfelbaum&lt;marcel.apfelbaum@gmail.com>
Signed-off-by: default avatarMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
Message-id: 20190507080501.26712-1-marcel.apfelbaum@gmail.com
[fixed malformed patch, rebase to master]
Signed-off-by: default avatarMarcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 962cf8fd
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -92,14 +92,18 @@ void surface_gl_update_texture(QemuGLShader *gls,

    assert(gls);

    if (surface->texture) {
        glBindTexture(GL_TEXTURE_2D, surface->texture);
        glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
                  surface_stride(surface) / surface_bytes_per_pixel(surface));
                      surface_stride(surface)
                      / surface_bytes_per_pixel(surface));
        glTexSubImage2D(GL_TEXTURE_2D, 0,
                        x, y, w, h,
                        surface->glformat, surface->gltype,
                        data + surface_stride(surface) * y
                        + surface_bytes_per_pixel(surface) * x);
    }
}

void surface_gl_render_texture(QemuGLShader *gls,
                               DisplaySurface *surface)