Hello,
For my ocaml-rdf bindings, I encounter the following problem:
I create a model, then a query and execute the query. If the model was
freed (because it was reclaimed by the garbage collector which then calls
the librdf_free_model function), it seems that the model reference in the query
becomes invalid (I get a segfault).
The attached patch (apparently) solves the problem, but is it the right way
to go ?
What it does: increment reference count to model when executing the query,
free the model when terminating the query.
Regards,
--
Maxence Guesdon
diff --git a/src/rdf_query_rasqal.c b/src/rdf_query_rasqal.c
index d499700..e99d884 100644
--- a/src/rdf_query_rasqal.c
+++ b/src/rdf_query_rasqal.c
@@ -153,6 +153,9 @@ librdf_query_rasqal_terminate(librdf_query* query)
if(context->uri)
librdf_free_uri(context->uri);
+
+ if(context->model)
+ librdf_free_model(context->model);
}
@@ -697,6 +700,7 @@ librdf_query_rasqal_execute(librdf_query* query, librdf_model* model)
librdf_query_results* results;
context->model = model;
+ librdf_model_add_reference(model);
/* This assumes raptor's URI implementation is librdf_uri */
if(rasqal_query_prepare(context->rq, context->query_string,
_______________________________________________
redland-dev mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-dev