Commit d48f4c3b authored by Paul Eggert's avatar Paul Eggert

Port to NetBSD tzalloc

Problem reported by Valery Ushakov (Bug#30738).
* src/editfns.c (xtzalloc): Remove.
(invalid_time_zone_specification): New function.
(tzlookup): Port to NetBSD, where tzalloc can fail when the TZ
string has an invalid value.
parent f1c48b0e
...@@ -117,14 +117,10 @@ emacs_mktime_z (timezone_t tz, struct tm *tm) ...@@ -117,14 +117,10 @@ emacs_mktime_z (timezone_t tz, struct tm *tm)
return t; return t;
} }
/* Allocate a timezone, signaling on failure. */ static _Noreturn void
static timezone_t invalid_time_zone_specification (Lisp_Object zone)
xtzalloc (char const *name)
{ {
timezone_t tz = tzalloc (name); xsignal2 (Qerror, build_string ("Invalid time zone specification"), zone);
if (!tz)
memory_full (SIZE_MAX);
return tz;
} }
/* Free a timezone, except do not free the time zone for local time. /* Free a timezone, except do not free the time zone for local time.
...@@ -205,9 +201,15 @@ tzlookup (Lisp_Object zone, bool settz) ...@@ -205,9 +201,15 @@ tzlookup (Lisp_Object zone, bool settz)
} }
} }
else else
xsignal2 (Qerror, build_string ("Invalid time zone specification"), invalid_time_zone_specification (zone);
zone);
new_tz = xtzalloc (zone_string); new_tz = tzalloc (zone_string);
if (!new_tz)
{
if (errno == ENOMEM)
memory_full (SIZE_MAX);
invalid_time_zone_specification (zone);
}
} }
if (settz) if (settz)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment