TT#60502 fix PATCH removal by value when multiple elements are removed

* elements must be removed reversed so last index is removed first,
      otherwise the list "for removal" becomes out of sync with the
      "current elements" causing wrong values to be removed, or an
      out of bounds index array error

Change-Id: I9ab9bce8205169bc7841c51f37743ab17946cc11
changes/03/30703/1
Kirill Solomko 6 years ago
parent a5537e8a37
commit ffdb2d0010

@ -867,14 +867,14 @@ sub process_patch_description {
if ($found_count == $remove_index) {
#if we want to use patch info to try to make clear changes, we shouldn't use replace
#from the other pov, if we requested 10000 removals, we will have 10000 new op entries
push @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i };
unshift @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i };
$removal_done = 1;
last;
} else {
$found_count++;
}
} else {
push @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i };
unshift @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i };
}
}
}

Loading…
Cancel
Save