gallium: Check for OOM condition when creating a sampler view.
[mesa.git] / src / gallium / drivers / svga / svga_pipe_sampler.c
index ebd1b9499728f4b57fa5741b08f691439751fdc9..82d525ca33f90fe93492f4b5ed6a7ad730c756c9 100644 (file)
@@ -183,11 +183,13 @@ svga_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;
 }