pitrou commented on code in PR #45498:
URL: https://github.com/apache/arrow/pull/45498#discussion_r1952506563


##########
cpp/src/arrow/csv/parser.cc:
##########
@@ -172,11 +172,17 @@ class ResizableValueDescWriter : public 
ValueDescWriter<ResizableValueDescWriter
 
   void PushValue(ParsedValueDesc v) {
     if (ARROW_PREDICT_FALSE(values_size_ == values_capacity_)) {
-      values_capacity_ = values_capacity_ * 2;
-      status_ &= values_buffer_->Resize(values_capacity_ * sizeof(*values_));
-      values_ = 
reinterpret_cast<ParsedValueDesc*>(values_buffer_->mutable_data());
+      int64_t new_capacity = values_capacity_ * 2;
+      auto resize_status = values_buffer_->Resize(new_capacity * 
sizeof(*values_));
+      if (resize_status.ok()) {
+        values_ = 
reinterpret_cast<ParsedValueDesc*>(values_buffer_->mutable_data());
+        values_capacity_ = new_capacity;
+      }
+      status_ &= std::move(resize_status);
+    }
+    if (ARROW_PREDICT_TRUE(status_.ok())) {

Review Comment:
   As mentioned by @mapleFU above, the pointer might not be valid anymore if 
the resize failed.
   
   Also, this is less performance-critical as this is normally run only on the 
first line of data.



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