Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | commit d2120bdb06c9aacc470bb346d6bc2071c2e0749d |
michael@0 | 2 | Author: Jeff Muizelaar <jmuizelaar@mozilla.com> |
michael@0 | 3 | Date: Fri Mar 12 15:32:09 2010 -0500 |
michael@0 | 4 | |
michael@0 | 5 | BGR |
michael@0 | 6 | |
michael@0 | 7 | diff --git a/src/cairo-surface.c b/src/cairo-surface.c |
michael@0 | 8 | index 332e3ab..4a1d6a0 100644 |
michael@0 | 9 | --- a/src/cairo-surface.c |
michael@0 | 10 | +++ b/src/cairo-surface.c |
michael@0 | 11 | @@ -1501,7 +1501,9 @@ static void |
michael@0 | 12 | _wrap_release_source_image (void *data) |
michael@0 | 13 | { |
michael@0 | 14 | struct acquire_source_image_data *acquire_data = data; |
michael@0 | 15 | - _cairo_surface_release_source_image (acquire_data->src, acquire_data->image, acquire_data->image_extra); |
michael@0 | 16 | + _cairo_surface_release_source_image (acquire_data->src, |
michael@0 | 17 | + acquire_data->image, |
michael@0 | 18 | + acquire_data->image_extra); |
michael@0 | 19 | free(data); |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | @@ -1515,42 +1517,47 @@ _wrap_image (cairo_surface_t *src, |
michael@0 | 23 | cairo_image_surface_t *surface; |
michael@0 | 24 | cairo_status_t status; |
michael@0 | 25 | |
michael@0 | 26 | - struct acquire_source_image_data *data = malloc(sizeof(*data)); |
michael@0 | 27 | + struct acquire_source_image_data *data = malloc (sizeof (*data)); |
michael@0 | 28 | + if (unlikely (data == NULL)) |
michael@0 | 29 | + return _cairo_error (CAIRO_STATUS_NO_MEMORY); |
michael@0 | 30 | data->src = src; |
michael@0 | 31 | data->image = image; |
michael@0 | 32 | data->image_extra = image_extra; |
michael@0 | 33 | |
michael@0 | 34 | - surface = (cairo_image_surface_t*)cairo_image_surface_create_for_data (image->data, |
michael@0 | 35 | - image->format, |
michael@0 | 36 | - image->width, |
michael@0 | 37 | - image->height, |
michael@0 | 38 | - image->stride); |
michael@0 | 39 | + surface = (cairo_image_surface_t*) |
michael@0 | 40 | + _cairo_image_surface_create_with_pixman_format (image->data, |
michael@0 | 41 | + image->pixman_format, |
michael@0 | 42 | + image->width, |
michael@0 | 43 | + image->height, |
michael@0 | 44 | + image->stride); |
michael@0 | 45 | status = surface->base.status; |
michael@0 | 46 | - if (status) |
michael@0 | 47 | + if (status) { |
michael@0 | 48 | + free (data); |
michael@0 | 49 | return status; |
michael@0 | 50 | + } |
michael@0 | 51 | |
michael@0 | 52 | status = _cairo_user_data_array_set_data (&surface->base.user_data, |
michael@0 | 53 | - &wrap_image_key, |
michael@0 | 54 | - data, |
michael@0 | 55 | - _wrap_release_source_image); |
michael@0 | 56 | + &wrap_image_key, |
michael@0 | 57 | + data, |
michael@0 | 58 | + _wrap_release_source_image); |
michael@0 | 59 | if (status) { |
michael@0 | 60 | cairo_surface_destroy (&surface->base); |
michael@0 | 61 | + free (data); |
michael@0 | 62 | return status; |
michael@0 | 63 | } |
michael@0 | 64 | -/* |
michael@0 | 65 | - pixman_image_set_component_alpha (surface->pixman_image, |
michael@0 | 66 | - pixman_image_get_component_alpha (image->pixman_image)); |
michael@0 | 67 | -*/ |
michael@0 | 68 | + |
michael@0 | 69 | + pixman_image_set_component_alpha ( |
michael@0 | 70 | + surface->pixman_image, |
michael@0 | 71 | + pixman_image_get_component_alpha (image->pixman_image)); |
michael@0 | 72 | + |
michael@0 | 73 | *out = surface; |
michael@0 | 74 | return CAIRO_STATUS_SUCCESS; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | - |
michael@0 | 78 | /** |
michael@0 | 79 | * _cairo_surface_clone_similar: |
michael@0 | 80 | * @surface: a #cairo_surface_t |
michael@0 | 81 | * @src: the source image |
michael@0 | 82 | - * @content: target content mask |
michael@0 | 83 | * @src_x: extent for the rectangle in src we actually care about |
michael@0 | 84 | * @src_y: extent for the rectangle in src we actually care about |
michael@0 | 85 | * @width: extent for the rectangle in src we actually care about |
michael@0 | 86 | @@ -1627,12 +1634,12 @@ _cairo_surface_clone_similar (cairo_surface_t *surface, |
michael@0 | 87 | _cairo_surface_release_source_image (src, image, image_extra); |
michael@0 | 88 | } else { |
michael@0 | 89 | status = |
michael@0 | 90 | - surface->backend->clone_similar (surface, &image->base, |
michael@0 | 91 | - src_x, src_y, |
michael@0 | 92 | - width, height, |
michael@0 | 93 | - clone_offset_x, |
michael@0 | 94 | - clone_offset_y, |
michael@0 | 95 | - clone_out); |
michael@0 | 96 | + surface->backend->clone_similar (surface, &image->base, |
michael@0 | 97 | + src_x, src_y, |
michael@0 | 98 | + width, height, |
michael@0 | 99 | + clone_offset_x, |
michael@0 | 100 | + clone_offset_y, |
michael@0 | 101 | + clone_out); |
michael@0 | 102 | cairo_surface_destroy(&image->base); |
michael@0 | 103 | } |
michael@0 | 104 | } |