From cab56c5265ea8724fb93d04fcf0ca514df1147da Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 17 Jun 2022 21:32:31 +0200 Subject: [PATCH] Only parse SOURCE_DATE_EPOCH once. --- magick/timer.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/magick/timer.c b/magick/timer.c index def7248156..69d22d99e6 100644 --- a/magick/timer.c +++ b/magick/timer.c @@ -326,26 +326,31 @@ MagickExport double GetElapsedTime(TimerInfo *time_info) */ MagickExport time_t GetMagickTime(void) { - static const char - *source_date_epoch = (const char *) NULL; + static time_t + constant_magick_time = 0; static MagickBooleanType epoch_initalized = MagickFalse; if (epoch_initalized == MagickFalse) { + const char + *source_date_epoch; + source_date_epoch=getenv("SOURCE_DATE_EPOCH"); - epoch_initalized=MagickTrue; - } - if (source_date_epoch != (const char *) NULL) - { - time_t - epoch; + if (source_date_epoch != (const char *) NULL) + { + time_t + epoch; - epoch=(time_t) StringToDouble(source_date_epoch,(char **) NULL); - if ((epoch > 0) && (epoch <= time((time_t *) NULL))) - return(epoch); + epoch=(time_t) StringToDouble(source_date_epoch,(char **) NULL); + if ((epoch > 0) && (epoch <= time((time_t *) NULL))) + constant_magick_time=epoch; + } + epoch_initalized=MagickTrue; } + if (constant_magick_time != 0) + return(constant_magick_time); return(time((time_t *) NULL)); }