]> git.ipfire.org Git - location/libloc.git/blobdiff - src/writer.c
writer: Free countries when the writer is being destroyed
[location/libloc.git] / src / writer.c
index 160650fa316d1519a8d6705855cebfbedede088c..2f09b56b92c018c448a9861b87e7c8713aa32df6 100644 (file)
@@ -154,6 +154,14 @@ static void loc_writer_free(struct loc_writer* writer) {
                free(writer->as);
        }
 
+       // Unref all countries
+       if (writer->countries) {
+               for (unsigned int i = 0; i < writer->countries_count; i++) {
+                       loc_country_unref(writer->countries[i]);
+               }
+               free(writer->countries);
+       }
+
        // Release network tree
        if (writer->networks)
                loc_network_tree_unref(writer->networks);