summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Beckett <dave@dajobe.org>2008-06-16 02:57:09 +0000
committerDave Beckett <dave@dajobe.org>2008-06-16 02:57:09 +0000
commit3697eb85a2d03636a4d236cc845776323e5bcdbe (patch)
tree968e948772c8a19a84e074f027e1ab55aa154b74
parentc53287f75172d093159fe3262a4af2274516b4ad (diff)
downloadraptor-3697eb85a2d03636a4d236cc845776323e5bcdbe.tar.gz
GIT commit 8892f4056d9486d7bdd0cc89fe12b3a863a4d418
(rdfa_free_context): rewrite rdfa_free_list(context->context_stack) call to look and do a proper rdfa_free_context() on each returned item that is not ourself. Still leaks one malloc but does not crash parser on error.
-rw-r--r--librdfa/rdfa.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/librdfa/rdfa.c b/librdfa/rdfa.c
index d695d2f6..724b596c 100644
--- a/librdfa/rdfa.c
+++ b/librdfa/rdfa.c
@@ -1167,9 +1167,19 @@ void rdfa_free_context(rdfacontext* context)
rdfa_free_list(context->local_incomplete_triples);
}
+ // this field is not NULL only on the rdfacontext* at the top of the stack
if(context->context_stack != NULL)
{
- rdfa_free_list(context->context_stack);
+ void* rval;
+ // free the stack ensuring that we do not delete this context if
+ // it is in the list (which it may be, if parsing ended on error)
+ do {
+ rval=rdfa_pop_item(context->context_stack);
+ if(rval && rval != context)
+ rdfa_free_context(rval);
+ } while(rval);
+ free(context->context_stack->items);
+ free(context->context_stack);
}
if(context->working_buffer != NULL)