diff --git a/src/aws/flb_aws_util.c b/src/aws/flb_aws_util.c index 3ca93bd9a8f..01a84187a79 100644 --- a/src/aws/flb_aws_util.c +++ b/src/aws/flb_aws_util.c @@ -745,6 +745,7 @@ flb_sds_t flb_get_s3_key(const char *format, time_t time, const char *tag, flb_sds_t tmp_key = NULL; flb_sds_t tmp_tag = NULL; struct tm gmt = {0}; + time_t gmt_tm; if (strlen(format) > S3_KEY_SIZE){ flb_warn("[s3_key] Object key length is longer than the 1024 character limit."); @@ -888,7 +889,8 @@ flb_sds_t flb_get_s3_key(const char *format, time_t time, const char *tag, tmp_key = NULL; flb_free(random_alphanumeric); - if (!gmtime_r(&time, &gmt)) { + gmt_tm = gmtime_r(&time, &gmt); + if (!gmt_tm) { flb_error("[s3_key] Failed to create timestamp."); goto error; }