[Mesa-dev] [PATCH 3/6] meta: react to errors in create_texture_for_pbo()
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Tue Feb 10 03:49:50 PST 2015
Check if we got requested temporary buffers and no NULL
pointer.
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
In original patch there was missing '*'s for tmp_pbo and tmp_tex.
tmp_pbo will not get value if end up in rehashing and rehashing fails.
If tmp_tex does not get value there is already GL_OUT_OF_MEMORY.
Added here check for tex_image which I initially somehow missed.
/Juha-Pekka
src/mesa/drivers/common/meta_tex_subimage.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c
index 68c8273..98bab8d 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -81,7 +81,10 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
} else {
assert(create_pbo);
+ *tmp_pbo = -1;
_mesa_GenBuffers(1, tmp_pbo);
+ if (*tmp_pbo == -1)
+ 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
@@ -97,7 +100,13 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
_mesa_BindBuffer(pbo_target, 0);
}
+ *tmp_tex = -1;
_mesa_GenTextures(1, tmp_tex);
+ if (*tmp_tex == -1) {
+ _mesa_DeleteBuffers(1, tmp_pbo);
+ return NULL;
+ }
+
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;
@@ -106,6 +115,12 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
internal_format = _mesa_get_format_base_format(pbo_format);
tex_image = _mesa_get_tex_image(ctx, tex_obj, tex_obj->Target, 0);
+ if (!tex_image) {
+ _mesa_DeleteTextures(1, tmp_tex);
+ _mesa_DeleteBuffers(1, tmp_pbo);
+ return NULL;
+ }
+
_mesa_init_teximage_fields(ctx, tex_image, width, height, depth,
0, internal_format, pbo_format);
--
1.8.5.1
More information about the mesa-dev
mailing list