diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 857dee630b4a9aa2750c35a3cd62c5162cfef664..d20f8055c470d69fcb3b1a6e173fc0bf5eeff3b9 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -855,7 +855,7 @@ static int func_strftime(AVFilterContext *ctx, AVBPrint *bp,
     if (tag == 'L')
         localtime_r(&now, &tm);
     else
-        tm = *gmtime(&now);
+        tm = *gmtime_r(&now, &tm);
     av_bprint_strftime(bp, fmt, &tm);
     return 0;
 }