Commit c820094d authored by Michael Tremer's avatar Michael Tremer

perl: Release location context when opening the database fails

Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 74ad091d
......@@ -16,7 +16,7 @@ MODULE = Location PACKAGE = Location
struct loc_database *
init(file)
char * file;
char* file = NULL;
CODE:
struct loc_ctx* ctx = NULL;
......@@ -29,17 +29,24 @@ init(file)
// Open the database file for reading
FILE* f = fopen(file, "r");
if (!f) {
loc_unref(ctx);
croak("Could not open file for reading: %s: %s\n",
file, strerror(errno));
}
// Parse the database
struct loc_database *db = NULL;
struct loc_database* db = NULL;
err = loc_database_new(ctx, &db, f);
if (err) {
loc_unref(ctx);
croak("Could not read database: %s\n", file);
}
// Cleanup
loc_unref(ctx);
RETVAL = db;
OUTPUT:
RETVAL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment