File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -869,7 +869,9 @@ fn clonePayload(payload: Payload, allocator: Allocator) !Payload {
869869 var success = false ;
870870 defer if (! success ) {
871871 // cleanup partial clones on error
872- for (0.. cloned_count ) | j | {
872+ var j : usize = cloned_count ;
873+ while (j > 0 ) {
874+ j -= 1 ;
873875 new_arr [j ].free (allocator );
874876 }
875877 allocator .free (new_arr );
@@ -889,13 +891,7 @@ fn clonePayload(payload: Payload, allocator: Allocator) !Payload {
889891 var new_map = Map .init (allocator );
890892 var success = false ;
891893 defer if (! success ) {
892- // Free any partially-inserted keys/values on error before deinit
893- var it2 = new_map .map .iterator ();
894- while (it2 .next ()) | entry | {
895- entry .key_ptr .* .free (allocator );
896- entry .value_ptr .* .free (allocator );
897- }
898- new_map .deinit ();
894+ (Payload { .map = new_map }).free (allocator );
899895 };
900896
901897 // Clone all entries
You can’t perform that action at this time.
0 commit comments