gallium: Check for OOM condition when creating a sampler view.
[mesa.git] / src / gallium / drivers / llvmpipe / lp_state_sampler.c
index 2df86a081484e5d0563b5678a9c93eba5b29e70e..2645441b58c9460a108bd296dffeab45687d2394 100644 (file)
@@ -170,11 +170,13 @@ llvmpipe_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;
 }