[Mesa-dev] [PATCH] st/mesa: don't dereference stObj->pt if NULL

Brian Paul brianp at vmware.com
Sat Sep 14 08:37:09 PDT 2013


On 09/13/2013 08:15 PM, Dave Airlie wrote:
> It seems a user app can get us into this state, I trigger the fail
> running fbo-maxsize inside virgl, it fails to create the backing
> storage for the texture object, but then segfaults here when it
> should fail the completeness test.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>   src/mesa/state_tracker/st_cb_fbo.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
> index 77aaccd..09daded 100644
> --- a/src/mesa/state_tracker/st_cb_fbo.c
> +++ b/src/mesa/state_tracker/st_cb_fbo.c
> @@ -505,6 +505,9 @@ st_validate_attachment(struct gl_context *ctx,
>      if (!stObj)
>         return GL_FALSE;
>
> +   if (!stObj->pt)
> +      return GL_FALSE;
> +
>      format = stObj->pt->format;
>      texFormat = att->Renderbuffer->TexImage->TexFormat;
>
>

You could otherwise fold that into the previous check:

if (!stObj || !stObj->pt)
    return;


but either way is OK.

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list