Please do not convert NULL to char - this doesn't work
Issue #157
resolved
Zero-terminator isn’t represented by NULL. NULL is a null-pointer.
Please apply this patch:
--- src/io/WriteNCDF.cpp.orig 2021-11-12 00:54:52 UTC
+++ src/io/WriteNCDF.cpp
@@ -160,8 +160,8 @@ void WriteNCDF::time_and_date( char* time_string, char
strftime( date_string, TIME_STR_LEN, "%m/%d/%Y", local_time );
// Terminate with NULL character
- time_string[10] = (char)NULL;
- date_string[10] = (char)NULL;
+ time_string[10] = (char)0;
+ date_string[10] = (char)0;
}
ErrorCode WriteNCDF::write_file( const char* exodus_file_name, const bool overwrite, const FileOptions& opts,
Comments (5)
-
-
reporter I don’t have permissions to create a pull request on BB.
Could you please just apply the patch?
Thanks!
-
Canonical way of writing a null byte to a character array is:
time_string[TIME_STR_LEN - 1] = '\0';
-
PR #627 now addresses this issue.
-
- changed status to resolved
- Log in to comment
Fair enough. Good catch. Do you mind submitting a PR? Can also use
time_string[10] = '\0';
for clarity.