gallium: Check for OOM condition when creating a sampler view.
[mesa.git] / src / gallium / drivers / i915 / i915_state.c
index 884abe622b34b2f4463afa5abab56997abbad1fd..e54997736f977ad8131b1cf22fb9d18a6efe6ed8 100644 (file)
@@ -598,11 +598,13 @@ i915_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }