Commit 58b5aa27 authored by Heiko Lewin's avatar Heiko Lewin
Browse files

Added checks for failed strdups in cairo-recording-surface.c

parent 7ac8220c
Pipeline #250937 passed with stages
in 30 minutes and 3 seconds
......@@ -1125,9 +1125,18 @@ _cairo_recording_surface_tag (void *abstract_surface,
command->begin = begin;
command->tag_name = strdup (tag_name);
if (unlikely (command->tag_name == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_COMMAND;
}
if (begin) {
if (attributes)
if (attributes) {
command->attributes = strdup (attributes);
if (unlikely (command->attributes == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_STRINGS;
}
}
status = _cairo_pattern_init_snapshot (&command->source.base, source);
if (unlikely (status))
......@@ -1144,9 +1153,9 @@ _cairo_recording_surface_tag (void *abstract_surface,
status = _cairo_recording_surface_commit (surface, &command->header);
if (unlikely (status)) {
if (begin)
goto CLEANUP_STRINGS;
else
goto CLEANUP_STYLE;
else
goto CLEANUP_STRINGS;
}
_cairo_recording_surface_destroy_bbtree (surface);
......@@ -1451,9 +1460,18 @@ _cairo_recording_surface_copy__tag (cairo_recording_surface_t *surface,
command->begin = src->tag.begin;
command->tag_name = strdup (src->tag.tag_name);
if (unlikely (command->tag_name == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err_command;
}
if (src->tag.begin) {
if (src->tag.attributes)
if (src->tag.attributes) {
command->attributes = strdup (src->tag.attributes);
if (unlikely (command->attributes == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err_command;
}
}
status = _cairo_pattern_init_copy (&command->source.base,
&src->tag.source.base);
......@@ -1472,9 +1490,9 @@ _cairo_recording_surface_copy__tag (cairo_recording_surface_t *surface,
status = _cairo_recording_surface_commit (surface, &command->header);
if (unlikely (status)) {
if (src->tag.begin)
goto err_command;
else
goto err_style;
else
goto err_command;
}
return CAIRO_STATUS_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment