Mesa (master): swrast: move null pointer check earlier in _swrast_map_teximage()
Brian Paul
brianp at kemper.freedesktop.org
Thu Apr 24 14:34:30 UTC 2014
Module: Mesa
Branch: master
Commit: 1a7fa8b2ebad2e07f57a430c8c77558bb07b0151
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a7fa8b2ebad2e07f57a430c8c77558bb07b0151
Author: Brian Paul <brianp at vmware.com>
Date: Wed Apr 23 09:57:11 2014 -0600
swrast: move null pointer check earlier in _swrast_map_teximage()
There's no reason to compute texel size, stride, etc. if there's no
image data to map.
Reviewed-by: José Fonseca <jfonseca at vmware.com>
---
src/mesa/swrast/s_texture.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index cbfa26b..9273e94 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -218,6 +218,15 @@ _swrast_map_teximage(struct gl_context *ctx,
check_map_teximage(texImage, slice, x, y, w, h);
+ if (!swImage->Buffer) {
+ /* Either glTexImage was called with a NULL <pixels> argument or
+ * we ran out of memory when allocating texture memory,
+ */
+ *mapOut = NULL;
+ *rowStrideOut = 0;
+ return;
+ }
+
texelSize = _mesa_get_format_bytes(texImage->TexFormat);
stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
@@ -225,12 +234,6 @@ _swrast_map_teximage(struct gl_context *ctx,
assert(x % bw == 0);
assert(y % bh == 0);
- if (!swImage->Buffer) {
- /* probably ran out of memory when allocating tex mem */
- *mapOut = NULL;
- return;
- }
-
/* This function can only be used with a swrast-allocated buffer, in which
* case ImageSlices is populated with pointers into Buffer.
*/
More information about the mesa-commit
mailing list