From 58441639b4b1e9cf349727463a026a400fca17a5 Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Mon, 8 Jan 2007 11:22:35 +0000 Subject: [PATCH] Fix two bugs found by valgrind: freeParser() wasn't freeing the outer struct, and the check for duplicate attribute names was overrunning the existing array. --- src/libCStreamedXML/parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libCStreamedXML/parser.c b/src/libCStreamedXML/parser.c index aa5f9f6..2e7ae84 100644 --- a/src/libCStreamedXML/parser.c +++ b/src/libCStreamedXML/parser.c @@ -454,7 +454,7 @@ int csxml_feedChar(struct csxml* ctx, char ch) default: if(ch != '=') ERROR("Invalid character in attribute name."); - for(try = 0; (size_t)try < ctx->elemAttrNames.size; ++try) { + for(try = 0; (size_t)try < ctx->elemAttrNames.len; ++try) { if(!strcmp(ctx->elemAttrNames.data[try].data, ctx->buffer.data)) ERROR("Duplicate attribute in element."); } @@ -645,6 +645,8 @@ void csxml_freeParser(struct csxml* ctx) list_free(&ctx->elemStack); list_free(&ctx->elemAttrNames); list_free(&ctx->elemAttrVals); + + free(ctx); }