diff options
| author | Paul Eggert | 2018-03-11 00:18:34 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-03-11 00:22:08 -0800 |
| commit | d48f4c3be13f8894964dad160f98ff8a7c7c3561 (patch) | |
| tree | 0d3a26ce56441ae8c63dce7c7dc0aadace6935dd /src | |
| parent | f1c48b0ec521744826ed43ae27eed0e152c472bf (diff) | |
| download | emacs-d48f4c3be13f8894964dad160f98ff8a7c7c3561.tar.gz emacs-d48f4c3be13f8894964dad160f98ff8a7c7c3561.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/editfns.c b/src/editfns.c index 3a34dd0980b..debe10572dc 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -117,14 +117,10 @@ emacs_mktime_z (timezone_t tz, struct tm *tm) | |||
| 117 | return t; | 117 | return t; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | /* Allocate a timezone, signaling on failure. */ | 120 | static _Noreturn void |
| 121 | static timezone_t | 121 | invalid_time_zone_specification (Lisp_Object zone) |
| 122 | xtzalloc (char const *name) | ||
| 123 | { | 122 | { |
| 124 | timezone_t tz = tzalloc (name); | 123 | xsignal2 (Qerror, build_string ("Invalid time zone specification"), zone); |
| 125 | if (!tz) | ||
| 126 | memory_full (SIZE_MAX); | ||
| 127 | return tz; | ||
| 128 | } | 124 | } |
| 129 | 125 | ||
| 130 | /* Free a timezone, except do not free the time zone for local time. | 126 | /* Free a timezone, except do not free the time zone for local time. |
| @@ -205,9 +201,15 @@ tzlookup (Lisp_Object zone, bool settz) | |||
| 205 | } | 201 | } |
| 206 | } | 202 | } |
| 207 | else | 203 | else |
| 208 | xsignal2 (Qerror, build_string ("Invalid time zone specification"), | 204 | invalid_time_zone_specification (zone); |
| 209 | zone); | 205 | |
| 210 | new_tz = xtzalloc (zone_string); | 206 | new_tz = tzalloc (zone_string); |
| 207 | if (!new_tz) | ||
| 208 | { | ||
| 209 | if (errno == ENOMEM) | ||
| 210 | memory_full (SIZE_MAX); | ||
| 211 | invalid_time_zone_specification (zone); | ||
| 212 | } | ||
| 211 | } | 213 | } |
| 212 | 214 | ||
| 213 | if (settz) | 215 | if (settz) |