OmBiradar commented on code in PR #50322:
URL: https://github.com/apache/arrow/pull/50322#discussion_r3508162546


##########
cpp/src/arrow/util/key_value_metadata.cc:
##########
@@ -100,6 +100,11 @@ Result<std::string> KeyValueMetadata::Get(std::string_view 
key) const {
 }
 
 Status KeyValueMetadata::Delete(int64_t index) {
+  if (ARROW_PREDICT_FALSE(index < 0 || std::cmp_greater_equal(index, 
values_.size()))) {
+    return Status::IndexError("Index out of bounds. Expected 0 to ",
+                              std::to_string(keys_.size() - 1), ", but got ",
+                              std::to_string(index));
+  }

Review Comment:
   I will address this, but I think a `std::max(0, keys_.size()-1)` is much 
better.



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