mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-27 19:50:11 +01:00
[cairo-pdf-surface] Free allstops on error.
Ensure the locally allocated resources are freed on the error paths.
This commit is contained in:
parent
79e6c0207c
commit
27de1869f5
1 changed files with 9 additions and 9 deletions
|
|
@ -1247,7 +1247,7 @@ _cairo_pdf_surface_emit_stitched_colorgradient (cairo_pdf_surface_t *surface,
|
|||
|
||||
#define COLOR_STOP_EPSILON 1e-6
|
||||
|
||||
static cairo_status_t
|
||||
static cairo_status_t
|
||||
_cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
|
||||
cairo_gradient_pattern_t *pattern,
|
||||
cairo_pdf_resource_t *color_function,
|
||||
|
|
@ -1263,9 +1263,8 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
|
|||
alpha_function->id = 0;
|
||||
|
||||
allstops = malloc ((pattern->n_stops + 2) * sizeof (cairo_pdf_color_stop_t));
|
||||
if (allstops == NULL) {
|
||||
if (allstops == NULL)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
stops = &allstops[1];
|
||||
n_stops = pattern->n_stops;
|
||||
|
|
@ -1304,7 +1303,7 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
|
|||
&stops[1],
|
||||
color_function);
|
||||
if (status)
|
||||
return status;
|
||||
goto BAIL;
|
||||
|
||||
if (emit_alpha) {
|
||||
status = cairo_pdf_surface_emit_alpha_linear_function (surface,
|
||||
|
|
@ -1312,7 +1311,7 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
|
|||
&stops[1],
|
||||
alpha_function);
|
||||
if (status)
|
||||
return status;
|
||||
goto BAIL;
|
||||
}
|
||||
} else {
|
||||
/* multiple stops: stitch. XXX possible optimization: regulary spaced
|
||||
|
|
@ -1323,7 +1322,7 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
|
|||
FALSE,
|
||||
color_function);
|
||||
if (status)
|
||||
return status;
|
||||
goto BAIL;
|
||||
|
||||
if (emit_alpha) {
|
||||
status = _cairo_pdf_surface_emit_stitched_colorgradient (surface,
|
||||
|
|
@ -1332,12 +1331,13 @@ _cairo_pdf_surface_emit_pattern_stops (cairo_pdf_surface_t *surface,
|
|||
TRUE,
|
||||
alpha_function);
|
||||
if (status)
|
||||
return status;
|
||||
goto BAIL;
|
||||
}
|
||||
}
|
||||
free (allstops);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
BAIL:
|
||||
free (allstops);
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_pdf_resource_t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue