summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-06-22 17:06:30 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-06-22 17:06:30 +0000
commita64feeffcabef7d7146fd362b59cb595e7761ff1 (patch)
tree60abb2bcfbcce9ae6ad2535fbc41eeb1f40a7187 /src/mesa
parent3ea9cf0d5ceb9c1451e9919e5252cbb2d0423fc7 (diff)
check for NULL pointer to glTexImage (fix verified by Adam Jackson)
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index 771e2bcadb..f9d6c2a657 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -956,19 +956,13 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
if (mml->width != width || mml->height != height) {
/* rescale the image to overcome 1:8 aspect limitation */
GLvoid *tempImage;
+ /* allocate temporary image */
tempImage = MALLOC(width * height * texelBytes);
if (!tempImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
}
- /* unpack image, apply transfer ops and store in tempImage */
- texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
- texImage->TexFormat, tempImage,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * texelBytes, /* dstRowStride */
- 0, /* dstImageStride */
- width, height, 1,
- format, type, pixels, packing);
+ /* allocate texture memory */
assert(!texImage->Data);
texImage->Data = MESA_PBUFFER_ALLOC(mml->width * mml->height * texelBytes);
if (!texImage->Data) {
@@ -976,11 +970,22 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
FREE(tempImage);
return;
}
- _mesa_rescale_teximage2d(texelBytes,
- mml->width * texelBytes, /* dst stride */
- width, height,
- mml->width, mml->height,
- tempImage /*src*/, texImage->Data /*dst*/ );
+ if (pixels) {
+ /* unpack image, apply transfer ops and store in tempImage */
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, tempImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ /* rescale */
+ _mesa_rescale_teximage2d(texelBytes,
+ mml->width * texelBytes, /* dst stride */
+ width, height,
+ mml->width, mml->height,
+ tempImage /*src*/, texImage->Data /*dst*/ );
+ }
FREE(tempImage);
}
else {
@@ -992,13 +997,15 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
return;
}
/* unpack image, apply transfer ops and store in texImage->Data */
- texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
- texImage->TexFormat, texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- width * texelBytes, /* dstRowStride */
- 0, /* dstImageStride */
- width, height, 1,
- format, type, pixels, packing);
+ if (pixels) {
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ }
}
RevalidateTexture(ctx, texObj);