Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] db_gdbm: Set up module only after all erroneous situation



Hello,
I was calling addmodulefd and append_tied_name too early, when some errors could yet happen

--
Sebastian Gniazdowski
psprint /at/ zdharma.org
diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 35254b6..c4bb931 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -157,10 +157,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
 
     gdbm_errno=0;
     dbf = gdbm_open(resource_name, 0, read_write, 0666, 0);
-    if(dbf) {
-	addmodulefd(gdbm_fdesc(dbf), FDT_MODULE);
-        append_tied_name(pmname);
-    } else {
+    if(dbf == NULL) {
 	zwarnnam(nam, "error opening database file %s (%s)", resource_name, gdbm_strerror(gdbm_errno));
 	return 1;
     }
@@ -172,6 +169,9 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
 	return 1;
     }
 
+    addmodulefd(gdbm_fdesc(dbf), FDT_MODULE);
+    append_tied_name(pmname);
+
     tied_param->gsu.h = &gdbm_hash_gsu;
 
     /* Allocate parameter sub-gsu, fill dbf field. 


Messages sorted by: Reverse Date, Date, Thread, Author