dmitry-chirkov-dremio commented on code in PR #54684:
URL: https://github.com/apache/arrow/pull/54684#discussion_r4396815366


##########
cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc:
##########
@@ -1198,6 +1198,28 @@ Result<std::locale> GetLocale(const std::string& locale) 
{
   }
 }
 
+// Check if format string contains %z, %Ez, or (optionally) %Z
+static inline bool FormatHasZone(std::string_view format, bool 
include_zone_name = true) {
+  size_t cur = 0;
+  size_t count = 0;
+  while (cur < format.size() - 1) {

Review Comment:
   FormatHasZone crashes on an empty format. The loop condition “cur < 
format.size() - 1” wraps around for size 0, so the loop reads past the string. 
Locally, strftime of a timestamp without time zone with format "" dies with 
SIGBUS. Before this PR it returned empty strings. Try “cur + 1 < format.size()” 
plus add a test with an empty format for strftime. strptime with an empty 
format already crashes the same way in GetZone() before this PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to