[redland-dev] Redland MySQL double free()

Dave Beckett dave.beckett at bristol.ac.uk
Sun Dec 19 14:23:20 PST 2004


Off list I looked at Christopher's valgrind output and I think I found
the problem in the mysql storage, calling the stream destructor
explicitly.  The librdf_stream module then calls it itself once the
stream is destroyed, freeing things twice.

Morten and I discussed this further on IRC (#redland on
irc.freenode.net) and think this is the cause.  So deleting some of
these extra destructions should fix it.

The patch is for 0.9.19 librdf/rdf_storage_mysql.c as released.

Dave
-------------- next part --------------
--- redland-0.9.19/librdf/rdf_storage_mysql.c.orig	2004-12-19 22:16:16.000000000 +0000
+++ redland-0.9.19/librdf/rdf_storage_mysql.c	2004-12-19 22:17:34.000000000 +0000
@@ -1574,7 +1574,6 @@
     /* Make sure we have a statement object to return */
     if(!sos->current_statement) {
       if(!(sos->current_statement=librdf_new_statement(sos->storage->world))) {
-        librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
         return 1;
       }
     }
@@ -1596,17 +1595,14 @@
         if(row[part]) {
           if(!(node=librdf_new_node_from_uri_string(sos->storage->world,
                                                      (const unsigned char*)row[part]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else if(row[part+1]) {
           if(!(node=librdf_new_node_from_blank_identifier(sos->storage->world,
                                                            (const unsigned char*)row[part+1]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else {
-          librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
           return 1;
         }
         librdf_statement_set_subject(sos->current_statement,node);
@@ -1620,11 +1616,9 @@
         if(row[part]) {
           if(!(node=librdf_new_node_from_uri_string(sos->storage->world,
                                                      (const unsigned char*)row[part]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else {
-          librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
           return 1;
         }
         librdf_statement_set_predicate(sos->current_statement,node);
@@ -1638,13 +1632,11 @@
         if(row[part]) {
           if(!(node=librdf_new_node_from_uri_string(sos->storage->world,
                                                      (const unsigned char*)row[part]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else if(row[part+1]) {
           if(!(node=librdf_new_node_from_blank_identifier(sos->storage->world,
                                                            (const unsigned char*)row[part+1]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else if(row[part+2]) {
@@ -1657,11 +1649,9 @@
                                                         (const unsigned char*)row[part+2],
                                                         row[part+3],
                                                         datatype))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else {
-          librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
           return 1;
         }
         librdf_statement_set_object(sos->current_statement,node);
@@ -1675,13 +1665,11 @@
         if(row[part]) {
           if(!(node=librdf_new_node_from_uri_string(sos->storage->world,
                                                      (const unsigned char*)row[part]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else if(row[part+1]) {
           if(!(node=librdf_new_node_from_blank_identifier(sos->storage->world,
                                                            (const unsigned char*)row[part+1]))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else if(row[part+2]) {
@@ -1694,7 +1682,6 @@
                                                         (const unsigned char*)row[part+2],
                                                         row[part+3],
                                                         datatype))) {
-            librdf_storage_mysql_find_statements_in_context_finished((void*)sos);
             return 1;
           }
         } else


More information about the redland-dev mailing list