[yelp/yelp-3-0] [yelp-transform] Fixing memory corruption on aux document
- From: Shaun McCance <shaunm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [yelp/yelp-3-0] [yelp-transform] Fixing memory corruption on aux document
- Date: Mon, 19 Oct 2009 16:58:18 +0000 (UTC)
commit 9204bc120fb9877a5f494325d186c7dbf97612d9
Author: Shaun McCance <shaunm gnome org>
Date: Mon Oct 19 11:56:17 2009 -0500
[yelp-transform] Fixing memory corruption on aux document
libyelp/yelp-transform.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/libyelp/yelp-transform.c b/libyelp/yelp-transform.c
index 8dfd27d..3b04635 100644
--- a/libyelp/yelp-transform.c
+++ b/libyelp/yelp-transform.c
@@ -177,17 +177,22 @@ static void
yelp_transform_finalize (GObject *object)
{
YelpTransformPrivate *priv = GET_PRIV (object);
- /* We do not free input or aux. They belong to the caller, which
- must ensure they exist for the lifetime of the transform.
- */
+ xsltDocumentPtr xsltdoc;
+
if (priv->output)
xmlFreeDoc (priv->output);
if (priv->stylesheet)
xsltFreeStylesheet (priv->stylesheet);
- if (priv->context)
- xsltFreeTransformContext (priv->context);
+ /* We do not free input or aux. They belong to the caller, which
+ must ensure they exist for the lifetime of the transform. We
+ have to set priv->aux_xslt->doc (which is priv->aux) to NULL
+ before xsltFreeTransformContext. Otherwise it will be freed,
+ which we don't want.
+ */
if (priv->aux_xslt)
priv->aux_xslt->doc = NULL;
+ if (priv->context)
+ xsltFreeTransformContext (priv->context);
if (priv->error)
g_error_free (priv->error);
@@ -328,6 +333,9 @@ static void
transform_run (YelpTransform *transform)
{
YelpTransformPrivate *priv = GET_PRIV (transform);
+
+ debug_print (DB_FUNCTION, "entering\n");
+
priv->output = xsltApplyStylesheetUser (priv->stylesheet,
priv->input,
(const char **) priv->params,
@@ -371,6 +379,8 @@ transform_final (YelpTransform *transform)
{
YelpTransformPrivate *priv = GET_PRIV (transform);
+ debug_print (DB_FUNCTION, "entering\n");
+
if (priv->cancelled)
goto done;
@@ -496,7 +506,6 @@ xslt_yelp_aux (xmlXPathParserContextPtr ctxt, int nargs)
transform = YELP_TRANSFORM (tctxt->_private);
priv = GET_PRIV (transform);
- /* FIXME: pretty sure this eats transform->aux, memory corruption will follow */
priv->aux_xslt = xsltNewDocument (tctxt, priv->aux);
ret = xmlXPathNewNodeSet (xmlDocGetRootElement (priv->aux));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]