struct shm_surface_data *data = p;
wl_buffer_destroy(data->data.buffer);
- munmap(data->map, data->length);
+ if (data->map)
+ munmap(data->map, data->length);
}
static struct wl_shm_pool *
if (window && window->pool && data->length < window->pool_size) {
pool = window->pool;
map = window->pool_data;
+ data->map = NULL;
} else {
- pool = make_shm_pool(display, data->length, &data->map);
- map = data->map;
+ pool = make_shm_pool(display, data->length, &map);
+ data->map = map;
}
surface = cairo_image_surface_create_for_data (map,
rectangle->height,
stride, format);
- if (map == data->map)
+ if (data->map)
wl_shm_pool_destroy(pool);
return surface;