Skip to content

Commit b721697

Browse files
mstdokumacijinzhongjia
authored andcommitted
fix(PackWithLimits): remove unnecessary cleanup calls on error conditions
1 parent ad341f1 commit b721697

1 file changed

Lines changed: 0 additions & 6 deletions

File tree

src/msgpack.zig

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,7 +2862,6 @@ pub fn PackWithLimits(
28622862
while (true) {
28632863
// Check depth limit
28642864
if (parse_stack.items.len >= parse_limits.max_depth) {
2865-
cleanupParseStack(&parse_stack, allocator);
28662865
return MsgPackError.MaxDepthExceeded;
28672866
}
28682867

@@ -2904,7 +2903,6 @@ pub fn PackWithLimits(
29042903
// Validate string length
29052904
if (val.len > parse_limits.max_string_length) {
29062905
allocator.free(val);
2907-
cleanupParseStack(&parse_stack, allocator);
29082906
return MsgPackError.StringTooLong;
29092907
}
29102908

@@ -2916,7 +2914,6 @@ pub fn PackWithLimits(
29162914
// Validate binary length
29172915
if (val.len > parse_limits.max_bin_length) {
29182916
allocator.free(val);
2919-
cleanupParseStack(&parse_stack, allocator);
29202917
return MsgPackError.BinDataLengthTooLong;
29212918
}
29222919

@@ -2929,7 +2926,6 @@ pub fn PackWithLimits(
29292926

29302927
// Validate array length
29312928
if (len > parse_limits.max_array_length) {
2932-
cleanupParseStack(&parse_stack, allocator);
29332929
return MsgPackError.ArrayTooLarge;
29342930
}
29352931

@@ -2962,7 +2958,6 @@ pub fn PackWithLimits(
29622958

29632959
// Validate map size
29642960
if (len > parse_limits.max_map_size) {
2965-
cleanupParseStack(&parse_stack, allocator);
29662961
return MsgPackError.MapTooLarge;
29672962
}
29682963

@@ -2976,7 +2971,6 @@ pub fn PackWithLimits(
29762971
errdefer if (!map_owned) map.deinit();
29772972

29782973
const capacity = std.math.cast(u32, len) orelse {
2979-
cleanupParseStack(&parse_stack, allocator);
29802974
return MsgPackError.MapTooLarge;
29812975
};
29822976
try map.ensureTotalCapacity(capacity);

0 commit comments

Comments
 (0)