From 4ec994858927a132d3fc01e353dbe78ad6642016 Mon Sep 17 00:00:00 2001
From: Yavor Doganov <yavor@gnu.org>
Date: Mon, 17 Jul 2023 16:39:27 +0300
Subject: [PATCH 2/3] Retain/release abbrev in GSTimeZoneDetail

---
 ChangeLog           | 5 +++++
 Source/NSTimeZone.m | 8 ++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f1b3d9259..0be787811 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	* Source/NSTimeZone.m: Move #include "tzdb.h" a bit earlier so
 	that the POSIX_TZONES preprocessor conditional is correct.
+	([GSTimeZoneDetail
+	initWithTimeZone:withAbbrev:withOffset:withDST:]): Retain abbrev.
+	([GSTimeZoneDetail dealloc]): Release abbrev.
+	([NSTimeZone timeZoneArray]): Skip files *.zi, *.list and
+	leapseconds which are not zone files.
 
 2023-06-10 Riccardo Mottola <rm@gnu.org>
 
diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m
index 6cf4ca2cf..1809c888a 100644
--- a/Source/NSTimeZone.m
+++ b/Source/NSTimeZone.m
@@ -806,6 +806,7 @@ static NSMapTable	*absolutes = 0;
 
 - (void) dealloc
 {
+  RELEASE(abbrev);
   RELEASE(timeZone);
   DEALLOC
 }
@@ -824,7 +825,7 @@ static NSMapTable	*absolutes = 0;
 		withDST: (BOOL)isDST
 {
   timeZone = RETAIN(aZone);
-  abbrev = anAbbrev;		// NB. Depend on this being retained in aZone
+  abbrev = RETAIN(anAbbrev);
   offset = anOffset;
   is_dst = isDST;
   return self;
@@ -1854,7 +1855,10 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60);
 		  path = [zonedir stringByAppendingPathComponent: name];
 		  if ([mgr fileExistsAtPath: path isDirectory: &isDir]
                     && isDir == NO
-                    && [[path pathExtension] isEqual: @"tab"] == NO)
+                    && [[path pathExtension] isEqual: @"tab"] == NO
+                    && [[path pathExtension] isEqual: @"zi"] == NO
+                    && [[path pathExtension] isEqual: @"list"] == NO
+                    && [[path lastPathComponent] isEqual: @"leapseconds"] == NO)
 		    {
 		      zone = [zoneDictionary objectForKey: name];
 		      if (zone == nil)
-- 
2.40.1

