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. */
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);
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) {
stImage->level, zoffset,
flags);
- return screen->surface_map(screen, stImage->surface, flags);
+ if (stImage->surface)
+ return screen->surface_map(screen, stImage->surface, flags);
+ else
+ return NULL;
}