summaryrefslogtreecommitdiff
path: root/lib/time_rz.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/time_rz.c')
-rw-r--r--lib/time_rz.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/time_rz.c b/lib/time_rz.c
index 95438cf876e..8992c2e37e0 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -27,19 +27,15 @@
#include <time.h>
#include <errno.h>
-#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "flexmember.h"
+#include "idx.h"
#include "time-internal.h"
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
/* The approximate size to use for small allocation requests. This is
the largest "small" request for the GNU C library malloc. */
enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
@@ -125,14 +121,8 @@ save_abbr (timezone_t tz, struct tm *tm)
{
if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set)))
{
- size_t zone_size = strlen (zone) + 1;
- size_t zone_used = zone_copy - tz->abbrs;
- if (SIZE_MAX - zone_used < zone_size)
- {
- errno = ENOMEM;
- return false;
- }
- if (zone_used + zone_size < ABBR_SIZE_MIN)
+ idx_t zone_size = strlen (zone) + 1;
+ if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy)
extend_abbrs (zone_copy, zone, zone_size);
else
{