git diff b2307b2...e86b545 
diff --git a/CHANGES b/CHANGES
index 9b32053..248edcb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+4914.	[security]	A bug in zone database reference counting could lead to
+			a crash when multiple versions of a slave zone were
+			transferred from a master in close succession.
+			(CVE-2018-5736) [GL #134]
+
 	--- 9.12.1 released ---
 	--- 9.12.1rc2 released ---
 
diff --git a/lib/dns/zone.c b/lib/dns/zone.c
index fe3aa71..fc950ac 100644
--- a/lib/dns/zone.c
+++ b/lib/dns/zone.c
@@ -10360,7 +10360,7 @@ dump_done(void *arg, isc_result_t result) {
 			dns_db_t *zdb = NULL;
 			if (dns_zone_getdb(zone, &zdb) == ISC_R_SUCCESS) {
 				zone_journal_compact(zone, zdb, serial);
-				dns_db_detach(&db);
+				dns_db_detach(&zdb);
 			}
 		} else if (tresult == ISC_R_SUCCESS) {
 			compact = ISC_TRUE;
