[Mesa-dev] [PATCH 3/6] meta: react to NULL pointers in create_texture_for_pbo()
Jason Ekstrand
jason at jlekstrand.net
Mon Jan 26 07:42:12 PST 2015
On Jan 26, 2015 1:08 AM, "Juha-Pekka Heikkila" <juhapekka.heikkila at gmail.com>
wrote:
>
> Check if null pointers were given and bail out.
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> src/mesa/drivers/common/meta_tex_subimage.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c
b/src/mesa/drivers/common/meta_tex_subimage.c
> index 977ee5a..cd5218e 100644
> --- a/src/mesa/drivers/common/meta_tex_subimage.c
> +++ b/src/mesa/drivers/common/meta_tex_subimage.c
> @@ -82,6 +82,8 @@ create_texture_for_pbo(struct gl_context *ctx, bool
create_pbo,
> assert(create_pbo);
>
> _mesa_GenBuffers(1, tmp_pbo);
> + if (!tmp_pbo)
> + return NULL;
>
> /* We are not doing this inside meta_begin/end. However, we know
the
> * client doesn't have the given target bound, so we can go ahead
and
> @@ -98,6 +100,11 @@ create_texture_for_pbo(struct gl_context *ctx, bool
create_pbo,
> }
>
> _mesa_GenTextures(1, tmp_tex);
> + if (!tmp_tex) {
> + _mesa_DeleteBuffers(1, tmp_pbo);
> + return NULL;
As Ken said, those two pointers will never be null. The potential NULL
that coverity is complaining about is probably actually two lines down
where we look up the texture object.
> + }
> +
> tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
> tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
> tex_obj->Immutable = GL_TRUE;
> --
> 1.8.5.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150126/56bd9b43/attachment.html>
More information about the mesa-dev
mailing list