gallium: Check for OOM condition when creating a sampler view.
[mesa.git] / src / gallium / drivers / r300 / r300_state.c
index 09bbf6c60e2c03699021ef0b2f551684a95fb3c4..d73ec78fda85b3bd18ce67020f6b1fe55e800bf5 100644 (file)
@@ -980,11 +980,13 @@ r300_create_sampler_view(struct pipe_context *pipe,
    struct r300_context *r300 = r300_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;
 }