xmlstarlet/xmlstar-sf3266898.patch
2011-04-07 15:48:55 +02:00

36 lines
1005 B
Diff

From 348ee3d65a0f30983c72d43a15d371b47fea65f6 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Fri, 1 Apr 2011 17:41:03 -0400
Subject: [PATCH 1/1] don't write to curXPath[-1]
---
src/xml_elem.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/xml_elem.c b/src/xml_elem.c
index 69f3126..eaabcf2 100644
--- a/src/xml_elem.c
+++ b/src/xml_elem.c
@@ -163,7 +163,9 @@ void elStartElement(void *user_data, const xmlChar *name, const xmlChar **attrs)
*/
void elEndElement(void *user_data, const xmlChar *name)
{
- *(curXPath + xmlStrlen(curXPath) - xmlStrlen(name) - 1) = '\0';
+ int xlen = xmlStrlen(curXPath);
+ int nlen = xmlStrlen(name);
+ *(curXPath + xlen - nlen - (xlen == nlen?0:1)) = '\0';
depth--;
}
@@ -184,6 +186,7 @@ parse_xml_file(const char *filename)
ret = xmlSAXUserParseFile(&xmlSAX_handler, NULL, filename);
xmlCleanupParser();
+ xmlFree(curXPath);
return ret;
}
--
1.7.0.1