ColinLeeo commented on code in PR #739:
URL: https://github.com/apache/tsfile/pull/739#discussion_r2958334827


##########
cpp/src/cwrapper/arrow_c.cc:
##########
@@ -707,31 +620,24 @@ int TsBlockToArrowStruct(common::TsBlock& tsblock, 
ArrowArray* out_array,
         return common::E_OOM;
     }
 
+    for (uint32_t i = 0; i < column_count; ++i) {
+        children_arrays[i] = nullptr;
+    }
+
     for (uint32_t i = 0; i < column_count; ++i) {
         children_arrays[i] = static_cast<ArrowArray*>(
             common::mem_alloc(sizeof(ArrowArray), common::MOD_TSBLOCK));
         if (children_arrays[i] == nullptr) {

Review Comment:
   The cleanup routine after an error checks whether each pointer is null 
before freeing it. Without initialization, these pointers could contain garbage 
values, leading to undefined behavior. 



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