The function didn't properly handle the case where the requested capacity was
less than the existing capacity. This led to the loop limit being some huge
number and it writing past the end of the 'buffers' array.
Partially fixes:
dEQP-VK.renderpass.suballocation.multisample_resolve.r16g16b16a16_unorm
.max_attachments_8_samples_2
The test no longer hangs, but segfaults instead.
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23104>