diff --git a/icu4c/source/tools/toolutil/writesrc.cpp b/icu4c/source/tools/toolutil/writesrc.cpp index 55c2f277b33..3e055c98033 100644 --- a/icu4c/source/tools/toolutil/writesrc.cpp +++ b/icu4c/source/tools/toolutil/writesrc.cpp @@ -136,7 +136,7 @@ usrc_writeFileNameGeneratedBy( time(&t); lt=localtime(&t); - if(generator==nullptr) { + if(generator==nullptr && lt!=nullptr) { strftime(buffer, sizeof(buffer), "%Y-%m-%d", lt); fprintf(f, pattern, prefix, prefix, filename, prefix, prefix, buffer); } else {