fix for crash with new buildinfo, when gmtime() returns NULL

This commit is contained in:
Campbell Barton
2013-11-18 02:39:26 +11:00
parent b764fe58c5
commit 84c30edbdf
2 changed files with 15 additions and 3 deletions

View File

@@ -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,

View File

@@ -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