summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_texture.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-05-08 19:19:52 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-05-08 19:19:52 -0600
commit2a39dbe7364af5444b1eb43650dfc31ed09257dc (patch)
tree3ea7a9799e35a4b4d3a1ab036e4e483038169f87 /src/mesa/state_tracker/st_cb_texture.c
parent044d583ba12689cbe99098eb999854303de57f59 (diff)
gallium: fix out of tex memory crashes
Diffstat (limited to 'src/mesa/state_tracker/st_cb_texture.c')
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 3468b5f2a1..c0dba4cf2d 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -645,7 +645,8 @@ st_TexImage(GLcontext * ctx,
if (stImage->pt) {
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
- dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
+ if (stImage->surface)
+ dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
}
else {
/* Allocate regular memory and store the image there temporarily. */
@@ -663,6 +664,11 @@ st_TexImage(GLcontext * ctx,
texImage->Data = malloc(sizeInBytes);
}
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ return;
+ }
+
DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
width, height, depth, width * texelBytes, dstRowStride);
@@ -906,7 +912,8 @@ st_TexSubimage(GLcontext * ctx,
if (stImage->pt) {
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
PIPE_BUFFER_USAGE_CPU_WRITE);
- dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
+ if (stImage->surface)
+ dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
}
if (!texImage->Data) {