浏览代码

fix: handle remaining data in read_and_store_large_data when size > input

- Add logic to push any remaining data in current_builder after main loop
- Fixes edge case where partial cell data would be lost when requested size exceeds available input
- All existing tests pass, maintaining backward compatibility

Co-Authored-By: ayush.suresh@dourolabs.xyz <byteSlayer31037@gmail.com>
Devin AI 3 月之前
父节点
当前提交
5e14d51ad3
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      target_chains/ton/contracts/contracts/common/utils.fc

+ 6 - 0
target_chains/ton/contracts/contracts/common/utils.fc

@@ -74,6 +74,12 @@ Note:
         }
         }
     }
     }
     
     
+    ;; Push any remaining data in current_builder after the loop
+    if (current_builder.builder_bits() > 0) {
+        cell current_chunk = current_builder.end_cell();
+        chunk_list~tpush(current_chunk);
+    }
+    
     ;; Build forward chain: first chunk → second chunk → third chunk etc
     ;; Build forward chain: first chunk → second chunk → third chunk etc
     cell result = null();
     cell result = null();
     int chunk_count = chunk_list.tlen();
     int chunk_count = chunk_list.tlen();