@@ -41,12 +41,12 @@ ptime_b_slow(struct exttm* dst, const char* str, off_t& off_inout, ssize_t len)
4141{
4242 size_t zone_len = len - off_inout;
4343 stack_buf allocator;
44- auto * zone = allocator.allocate (zone_len + 1 );
44+ auto * zone = allocator.allocate (zone_len + 2 );
4545 const char * end_of_date;
4646
4747 memcpy (zone, &str[off_inout], zone_len);
4848 zone[zone_len] = ' \0 ' ;
49- if ((end_of_date = strptime (zone, " %b" , &dst->et_tm )) != NULL ) {
49+ if ((end_of_date = strptime (zone, " %b" , &dst->et_tm )) != nullptr ) {
5050 off_inout += end_of_date - zone;
5151 // Some formats append a dot, maybe to align a 3 letter abbrev with the
5252 // four letter ones?
@@ -68,14 +68,11 @@ ptime_b_slow(struct exttm* dst, const char* str, off_t& off_inout, ssize_t len)
6868 if (alpha_len > 0 && (alpha_len >= (off_t ) zone_len
6969 || zone[alpha_len] != ' .' ))
7070 {
71- auto * dotted = allocator.allocate (zone_len + 2 );
72- memcpy (dotted, zone, alpha_len);
73- dotted[alpha_len] = ' .' ;
74- memcpy (dotted + alpha_len + 1 , zone + alpha_len,
75- zone_len - alpha_len);
76- dotted[zone_len + 1 ] = ' \0 ' ;
77- if ((end_of_date = strptime (dotted, " %b" , &dst->et_tm )) != NULL ) {
78- auto consumed = end_of_date - dotted;
71+ memmove (zone + alpha_len + 1 , zone + alpha_len,
72+ zone_len - alpha_len + 1 );
73+ zone[alpha_len] = ' .' ;
74+ if ((end_of_date = strptime (zone, " %b" , &dst->et_tm )) != nullptr ) {
75+ auto consumed = end_of_date - zone;
7976 // Subtract the inserted dot from consumed length if strptime
8077 // consumed past it
8178 if (consumed > alpha_len) {
0 commit comments