Skip to content

Commit bb48056

Browse files
committed
Merge branch 'tb/bugreport-no-localtime'
Use of non-reentrant localtime() has been removed. * tb/bugreport-no-localtime: builtin/bugreport.c: use thread-safe localtime_r()
2 parents f2a75cb + 4f6460d commit bb48056

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/bugreport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
125125
struct strbuf report_path = STRBUF_INIT;
126126
int report = -1;
127127
time_t now = time(NULL);
128+
struct tm tm;
128129
char *option_output = NULL;
129130
char *option_suffix = "%Y-%m-%d-%H%M";
130131
const char *user_relative_path = NULL;
@@ -147,7 +148,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
147148
strbuf_complete(&report_path, '/');
148149

149150
strbuf_addstr(&report_path, "git-bugreport-");
150-
strbuf_addftime(&report_path, option_suffix, localtime(&now), 0, 0);
151+
strbuf_addftime(&report_path, option_suffix, localtime_r(&now, &tm), 0, 0);
151152
strbuf_addstr(&report_path, ".txt");
152153

153154
switch (safe_create_leading_directories(report_path.buf)) {

0 commit comments

Comments
 (0)