Skip to content

Commit

Permalink
Only parse SOURCE_DATE_EPOCH once.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jun 17, 2022
1 parent 70c6500 commit cab56c5
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions magick/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit cab56c5

Please sign in to comment.