edponce commented on a change in pull request #11064:
URL: https://github.com/apache/arrow/pull/11064#discussion_r700696937



##########
File path: cpp/src/arrow/util/value_parsing.h
##########
@@ -336,6 +439,21 @@ struct StringToSignedIntConverterMixin {
         return false;
       }
     }
+
+    // If its starts with 0x then its hex
+    if (*s == '0' && *(s + 1) == 'x'){
+      length -= 2;

Review comment:
       If there is a negative sign, then it is not a well-formed hex string.

##########
File path: cpp/src/arrow/util/value_parsing.h
##########
@@ -281,6 +371,19 @@ struct StringToUnsignedIntConverterMixin {
     if (ARROW_PREDICT_FALSE(length == 0)) {
       return false;
     }
+    // If its starts with 0x then its hex
+    if (*s == '0' && *(s + 1) == 'x'){
+      length -= 2;
+      s += 2;
+      // lets make sure that the length of the string is not too big

Review comment:
       Nit: You can probably not need to decrease `length` and consider the 
offset of `s` as the difference to consider. 

##########
File path: cpp/src/arrow/util/value_parsing.h
##########
@@ -281,6 +371,19 @@ struct StringToUnsignedIntConverterMixin {
     if (ARROW_PREDICT_FALSE(length == 0)) {
       return false;
     }
+    // If its starts with 0x then its hex
+    if (*s == '0' && *(s + 1) == 'x'){
+      length -= 2;
+      s += 2;
+      // lets make sure that the length of the string is not too big
+      if (!ARROW_PREDICT_TRUE(sizeof(value_type)*2 >= length)) {
+        return false;
+      }
+      if (!ARROW_PREDICT_TRUE(ParseHex(s, length, out))) {
+        return false;
+      }
+      return true; 
+    }

Review comment:
       You can simplify these checks and boolean result as
   ```c++
   return ARROW_PREDICT_TRUE((sizeof(value_type) * 2 >= length) && ParseHex(s, 
length, out));
   ```




-- 
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