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 | diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 2 | --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 3 | +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c |
michael@0 | 4 | @@ -2573,29 +2573,43 @@ static cairo_int_status_t |
michael@0 | 5 | |
michael@0 | 6 | if (style->dash && style->num_dashes) { |
michael@0 | 7 | #define STATIC_DASH 32 |
michael@0 | 8 | cairo_quartz_float_t sdash[STATIC_DASH]; |
michael@0 | 9 | cairo_quartz_float_t *fdash = sdash; |
michael@0 | 10 | unsigned int max_dashes = style->num_dashes; |
michael@0 | 11 | unsigned int k; |
michael@0 | 12 | |
michael@0 | 13 | - if (style->num_dashes%2) |
michael@0 | 14 | - max_dashes *= 2; |
michael@0 | 15 | - if (max_dashes > STATIC_DASH) |
michael@0 | 16 | - fdash = _cairo_malloc_ab (max_dashes, sizeof (cairo_quartz_float_t)); |
michael@0 | 17 | - if (fdash == NULL) |
michael@0 | 18 | - return _cairo_error (CAIRO_STATUS_NO_MEMORY); |
michael@0 | 19 | - |
michael@0 | 20 | - for (k = 0; k < max_dashes; k++) |
michael@0 | 21 | - fdash[k] = (cairo_quartz_float_t) style->dash[k % style->num_dashes]; |
michael@0 | 22 | - |
michael@0 | 23 | - CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes); |
michael@0 | 24 | - if (fdash != sdash) |
michael@0 | 25 | - free (fdash); |
michael@0 | 26 | + bool set_line_dash = false; |
michael@0 | 27 | + if (style->num_dashes % 2 == 0) { |
michael@0 | 28 | + for (k = 1; k < max_dashes; k++) { |
michael@0 | 29 | + if (style->dash[k]) { |
michael@0 | 30 | + set_line_dash = true; |
michael@0 | 31 | + break; |
michael@0 | 32 | + } |
michael@0 | 33 | + } |
michael@0 | 34 | + } else |
michael@0 | 35 | + set_line_dash = true; |
michael@0 | 36 | + |
michael@0 | 37 | + if (set_line_dash) { |
michael@0 | 38 | + if (style->num_dashes%2) |
michael@0 | 39 | + max_dashes *= 2; |
michael@0 | 40 | + if (max_dashes > STATIC_DASH) |
michael@0 | 41 | + fdash = _cairo_malloc_ab (max_dashes, sizeof (cairo_quartz_float_t)); |
michael@0 | 42 | + if (fdash == NULL) |
michael@0 | 43 | + return _cairo_error (CAIRO_STATUS_NO_MEMORY); |
michael@0 | 44 | + |
michael@0 | 45 | + for (k = 0; k < max_dashes; k++) |
michael@0 | 46 | + fdash[k] = (cairo_quartz_float_t) style->dash[k % style->num_dashes]; |
michael@0 | 47 | + |
michael@0 | 48 | + CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes); |
michael@0 | 49 | + if (fdash != sdash) |
michael@0 | 50 | + free (fdash); |
michael@0 | 51 | + } else |
michael@0 | 52 | + CGContextSetLineDash (state.context, 0, NULL, 0); |
michael@0 | 53 | } else |
michael@0 | 54 | CGContextSetLineDash (state.context, 0, NULL, 0); |
michael@0 | 55 | |
michael@0 | 56 | |
michael@0 | 57 | _cairo_quartz_cairo_path_to_quartz_context (path, state.context); |
michael@0 | 58 | |
michael@0 | 59 | _cairo_quartz_cairo_matrix_to_quartz (ctm, &strokeTransform); |
michael@0 | 60 | CGContextConcatCTM (state.context, strokeTransform); |