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.
This commit is contained in:
parent
c081c94d72
commit
58441639b4
|
@ -454,7 +454,7 @@ int csxml_feedChar(struct csxml* ctx, char ch)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(ch != '=') ERROR("Invalid character in attribute name.");
|
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))
|
if(!strcmp(ctx->elemAttrNames.data[try].data, ctx->buffer.data))
|
||||||
ERROR("Duplicate attribute in element.");
|
ERROR("Duplicate attribute in element.");
|
||||||
}
|
}
|
||||||
|
@ -645,6 +645,8 @@ void csxml_freeParser(struct csxml* ctx)
|
||||||
list_free(&ctx->elemStack);
|
list_free(&ctx->elemStack);
|
||||||
list_free(&ctx->elemAttrNames);
|
list_free(&ctx->elemAttrNames);
|
||||||
list_free(&ctx->elemAttrVals);
|
list_free(&ctx->elemAttrVals);
|
||||||
|
|
||||||
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue