]> git.ipfire.org Git - location/libloc.git/commitdiff
database: Free mmapped countries section
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Mar 2021 11:42:43 +0000 (11:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Mar 2021 11:42:43 +0000 (11:42 +0000)
This was a potential memory leak.

Reported-by: Gisle Vanem <gisle.vanem@gmail.com>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/database.c

index 4b8bf1d4bdddbc6511ef73962a6c7a43eb51ef43..b92a803d5d3db9a8be49049ee803d7a06f6180e2 100644 (file)
@@ -446,6 +446,13 @@ static void loc_database_free(struct loc_database* db) {
                        ERROR(db->ctx, "Could not unmap network nodes section: %s\n", strerror(errno));
        }
 
+       // Remove mapped countries section
+       if (db->countries_v1) {
+               r = munmap(db->countries_v1, db->countries_count * sizeof(*db->countries_v1));
+               if (r)
+                       ERROR(db->ctx, "Could not unmap countries section: %s\n", strerror(errno));
+       }
+
        if (db->pool)
                loc_stringpool_unref(db->pool);