From 997e5e05d70892222fb07c2d6ad483ad1e9a9607 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 4 Mar 2018 20:13:49 -0500 Subject: [PATCH 1/2] Fix system timezone memoization. The result of `get_system_tz` comes from a `STRING_ELT`, which seems to be automatically garbage collected, causing the static character pointer to point to an invalid location. Duplicating the string is a small leak, but prevents this invalid access. Signed-off-by: Elliott Sales de Andrade --- src/update.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/update.cpp b/src/update.cpp index 4cddbb1..1f4a694 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -95,7 +95,7 @@ const char* get_system_tz() { const char* local_tz() { // initialize once per session - static const char* SYS_TZ = get_system_tz(); + static const char* SYS_TZ = strdup(get_system_tz()); const char* tz_env = std::getenv("TZ"); if (tz_env == NULL) { return SYS_TZ; -- 2.14.3