diff --git a/libopendmarc/opendmarc_tld.c b/libopendmarc/opendmarc_tld.c
index 8ac45e8..0c04370 100644
--- a/libopendmarc/opendmarc_tld.c
+++ b/libopendmarc/opendmarc_tld.c
@@ -134,8 +134,11 @@
 		return (errno == 0) ? ENOMEM : errno;
 
 	fp = fopen(path_fname, "r");
-	if (fp == NULL)
-		return errno;
+	if (fp == NULL) {
+		ret = errno;
+		opendmarc_hash_shutdown(hashp);
+		return ret;
+	}
 
 	errno = 0;
 	while (fgets((char *)buf, sizeof buf, fp) != NULL)
