gallium: Check for OOM condition when creating a sampler view.
[mesa.git] / src / gallium / drivers / i965 / brw_pipe_sampler.c
index fbc3a07d61ecfc97d4531ed1d1d167c6dddb532b..d2aa2bc9f3579d9669ac5e7fdd83de87373479b0 100644 (file)
@@ -219,11 +219,13 @@ brw_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;
 }