Skip to content
This repository was archived by the owner on Dec 15, 2024. It is now read-only.

Commit 6a29f30

Browse files
committed
fixed gmtime() crash on Linux
1 parent fcdef60 commit 6a29f30

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Sources/SwiftFoundation/POSIXTime.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ public extension tm {
8080

8181
var seconds = UTCSecondsSince1970
8282

83+
// don't free!
84+
// The return value points to a statically allocated struct which might be overwritten by subsequent calls to any of the date and time functions.
85+
// http://linux.die.net/man/3/gmtime
8386
let timePointer = gmtime(&seconds)!
8487

85-
defer { free(timePointer) }
86-
8788
self = timePointer.pointee
8889
}
8990
}

0 commit comments

Comments
 (0)