mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
check for NULL pointer to glTexImage (fix verified by Adam Jackson)
This commit is contained in:
parent
3ea9cf0d5c
commit
a64feeffca
1 changed files with 27 additions and 20 deletions
|
|
@ -956,19 +956,13 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||||
if (mml->width != width || mml->height != height) {
|
if (mml->width != width || mml->height != height) {
|
||||||
/* rescale the image to overcome 1:8 aspect limitation */
|
/* rescale the image to overcome 1:8 aspect limitation */
|
||||||
GLvoid *tempImage;
|
GLvoid *tempImage;
|
||||||
|
/* allocate temporary image */
|
||||||
tempImage = MALLOC(width * height * texelBytes);
|
tempImage = MALLOC(width * height * texelBytes);
|
||||||
if (!tempImage) {
|
if (!tempImage) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* unpack image, apply transfer ops and store in tempImage */
|
/* allocate texture memory */
|
||||||
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);
|
|
||||||
assert(!texImage->Data);
|
assert(!texImage->Data);
|
||||||
texImage->Data = MESA_PBUFFER_ALLOC(mml->width * mml->height * texelBytes);
|
texImage->Data = MESA_PBUFFER_ALLOC(mml->width * mml->height * texelBytes);
|
||||||
if (!texImage->Data) {
|
if (!texImage->Data) {
|
||||||
|
|
@ -976,11 +970,22 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||||
FREE(tempImage);
|
FREE(tempImage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mesa_rescale_teximage2d(texelBytes,
|
if (pixels) {
|
||||||
mml->width * texelBytes, /* dst stride */
|
/* unpack image, apply transfer ops and store in tempImage */
|
||||||
width, height,
|
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
||||||
mml->width, mml->height,
|
texImage->TexFormat, tempImage,
|
||||||
tempImage /*src*/, texImage->Data /*dst*/ );
|
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);
|
FREE(tempImage);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -992,13 +997,15 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* unpack image, apply transfer ops and store in texImage->Data */
|
/* unpack image, apply transfer ops and store in texImage->Data */
|
||||||
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
if (pixels) {
|
||||||
texImage->TexFormat, texImage->Data,
|
texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
|
||||||
0, 0, 0, /* dstX/Y/Zoffset */
|
texImage->TexFormat, texImage->Data,
|
||||||
width * texelBytes, /* dstRowStride */
|
0, 0, 0, /* dstX/Y/Zoffset */
|
||||||
0, /* dstImageStride */
|
width * texelBytes, /* dstRowStride */
|
||||||
width, height, 1,
|
0, /* dstImageStride */
|
||||||
format, type, pixels, packing);
|
width, height, 1,
|
||||||
|
format, type, pixels, packing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RevalidateTexture(ctx, texObj);
|
RevalidateTexture(ctx, texObj);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue