Cherry-pick https://gitlab.freedesktop.org/cairo/cairo/-/commit/c62c43a8c653f5e4d20ef868065d4f882df9768e draft
authorJonathan Kew <jkew@mozilla.com>
Wed, 14 Apr 2021 17:57:06 +0100
changeset 3667304 402d5260dadf182bca45b103f24d4629d67346af
parent 3667303 dcfa64c1b9a07e32389ac627848dbdf26355095a
child 3667305 b6dbf53bdb1467e6bb35d94655072474c0486a9e
push id683063
push userjkew@mozilla.com
push dateMon, 19 Apr 2021 13:15:26 +0000
treeherdertry@919daaf50d14 [default view] [failures only]
milestone89.0a1
Cherry-pick https://gitlab.freedesktop.org/cairo/cairo/-/commit/c62c43a8c653f5e4d20ef868065d4f882df9768e Fix a memory leak with cairo_tag_begin() + pdf
gfx/cairo/cairo/src/cairo-pdf-interchange.c
--- a/gfx/cairo/cairo/src/cairo-pdf-interchange.c
+++ b/gfx/cairo/cairo/src/cairo-pdf-interchange.c
@@ -1129,23 +1129,30 @@ static cairo_int_status_t
 
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
 	dest = calloc (1, sizeof (cairo_pdf_named_dest_t));
 	if (unlikely (dest == NULL))
 	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
 	status = _cairo_tag_parse_dest_attributes (attributes, &dest->attrs);
 	if (unlikely (status))
+	{
+	    free (dest);
 	    return status;
+	}
 
 	dest->page = _cairo_array_num_elements (&surface->pages);
 	init_named_dest_key (dest);
 	status = _cairo_hash_table_insert (ic->named_dests, &dest->base);
 	if (unlikely (status))
+	{
+	    free (dest->attrs.name);
+	    free (dest);
 	    return status;
+	}
 
 	_cairo_tag_stack_set_top_data (&ic->analysis_tag_stack, dest);
 	cairo_list_add_tail (&dest->extents.link, &ic->extents_list);
 	ic->num_dests++;
     }
 
     return status;
 }