fix for crash with new buildinfo, when gmtime() returns NULL
This commit is contained in:
@@ -7932,7 +7932,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
char build_commit_datetime[32];
|
||||
time_t temp_time = main->build_commit_timestamp;
|
||||
struct tm *tm = gmtime(&temp_time);
|
||||
strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm);
|
||||
if (LIKELY(tm)) {
|
||||
strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(build_commit_datetime, "date-unknown", sizeof(build_commit_datetime));
|
||||
}
|
||||
|
||||
printf("read file %s\n Version %d sub %d date %s hash %s\n",
|
||||
fd->relabase, main->versionfile, main->subversionfile,
|
||||
|
||||
@@ -1516,8 +1516,15 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
time_t temp_time = build_commit_timestamp;
|
||||
struct tm *tm = gmtime(&temp_time);
|
||||
strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm);
|
||||
strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm);
|
||||
if (LIKELY(tm)) {
|
||||
strftime(build_commit_date, sizeof(build_commit_date), "%Y-%m-%d", tm);
|
||||
strftime(build_commit_time, sizeof(build_commit_time), "%H:%M", tm);
|
||||
}
|
||||
else {
|
||||
const char *unknown = "date-unknown";
|
||||
BLI_strncpy(build_commit_date, unknown, sizeof(build_commit_date));
|
||||
BLI_strncpy(build_commit_time, unknown, sizeof(build_commit_time));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user