Skip to content

strptime does not zero tm struct before calling c_strptime #49

@nichannah

Description

@nichannah

man strptime gives an example code like the below:

   int
       main(void)
       {
           struct tm tm;
           char buf[255];

           memset(&tm, 0, sizeof(struct tm));
           strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
           strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm);
           puts(buf);
           exit(EXIT_SUCCESS);
       }

The tm struct is zeroed before calling. datetime-fortran strptime does not do this which means that depending on the time string/format parts of the tm struct can be left containing uninitialised values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions