From 2c41d4b44eae435f780bc3ba81978019a06fcf3d Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 3 Oct 2011 21:04:54 +0000 Subject: [PATCH] Add talloc destructor for object_params. svn path=/trunk/netsurf/; revision=12937 --- render/box_construct.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/render/box_construct.c b/render/box_construct.c index ba642f1f2..144d8d80c 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1343,6 +1343,24 @@ bool box_image(BOX_SPECIAL_PARAMS) } +/** + * Destructor for object_params, for elements + * + * \param b The object params being destroyed. + * \return 0 to allow talloc to continue destroying the tree. + */ +static int box_object_talloc_destructor(struct object_params *o) +{ + if (o->codebase != NULL) + nsurl_unref(o->codebase); + if (o->classid != NULL) + nsurl_unref(o->classid); + if (o->data != NULL) + nsurl_unref(o->data); + + return 0; +} + /** * Generic embedded object [13.3]. */ @@ -1366,6 +1384,9 @@ bool box_object(BOX_SPECIAL_PARAMS) params = talloc(content, struct object_params); if (!params) return false; + + talloc_set_destructor(params, box_object_talloc_destructor); + params->data = 0; params->type = 0; params->codetype = 0;