[Mesa-dev] [PATCH] swrast: Fix crash in sPriv->swrast_loader->getImage().
Brian Paul
brianp at vmware.com
Tue Sep 3 12:51:31 PDT 2013
On 09/01/2013 08:19 AM, Johannes Obermayr wrote:
> From: Egbert Eich <eich at freedesktop.org>
>
> When glXBindTexImageEXT is called and SWrast is used there will be a crash when
> sPriv->swrast_loader->getImage() is called from swrastSetTexBuffer2(). Reason:
> no memory has been allocated for the destination thus texImage->Data is NULL.
> Call ctx->Driver.TexImage2D() to initialize this. If memory has been allocated
> in a previous call free it first.
>
> Fixes: https://bugzilla.novell.com/show_bug.cgi?id=641297
>
> Signed-off-by: Egbert Eich <eich at freedesktop.org>
> Adapted-by: Stefan Dirsch <sndirsch at suse.com>
> Adapted-by: Tobias Johannes Klausmann <tobias.johannes.klausmann at mni.thm.de>
> ---
>
> I am not sure whether this patch from Q3/2010 is required these days. But
> openSUSE still applies it ...
> If "yes" it should also land in 9.2, 9.1, 9.0 and 8.0 branches.
>
> ---
> src/mesa/drivers/dri/swrast/swrast.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
> index 332c7b7..b1c67a9 100644
> --- a/src/mesa/drivers/dri/swrast/swrast.c
> +++ b/src/mesa/drivers/dri/swrast/swrast.c
> @@ -67,6 +67,7 @@
> static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
> GLint texture_format, __DRIdrawable *dPriv)
> {
> + GET_CURRENT_CONTEXT(ctx);
The current gl_context can be found at dri_ctx->Base as seen below in
several places.
> struct dri_context *dri_ctx;
> int x, y, w, h;
> __DRIscreen *sPriv = dPriv->driScreenPriv;
> @@ -98,6 +99,13 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
> _mesa_init_teximage_fields(&dri_ctx->Base, texImage,
> w, h, 1, 0, internalFormat, texFormat);
>
> + if (texImage->Data)
This won't work on master/9.2/9.1 (at least) since gl_texture_image
doesn't have a 'Data' field.
> + ctx->Driver.FreeTexImageData(ctx, texImage);
There's no such driver hook in recent Mesa.
> +
> + ctx->Driver.TexImage2D(ctx, target, 0, internalFormat,
> + w, h, 0, texture_format, GL_UNSIGNED_INT_8_8_8_8,
> + NULL, &ctx->Unpack, texObj, texImage);
If you just need to allocate texture memory you should probably call
ctx->Driver.AllocTextureImageBuffer().
> +
> sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Buffer,
> dPriv->loaderPrivate);
>
>
-Brian
More information about the mesa-dev
mailing list