mirror of
git://git.proxmox.com/git/perlmod.git
synced 2025-03-12 00:58:16 +03:00
array: avoid underflow when array is empty and more is zero
serializing an empty array triggered this. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> [rustfmt: Wolfgang Bumiller <w.bumiller@proxmox.com>] Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
dc04b1694f
commit
f053fb84ef
@ -102,6 +102,9 @@ impl Array {
|
||||
|
||||
/// Pre-extend the array to up to the specified length..
|
||||
pub fn reserve(&self, more: usize) {
|
||||
if more == 0 {
|
||||
return;
|
||||
}
|
||||
let idx = self.len() + more - 1;
|
||||
unsafe {
|
||||
ffi::RSPL_av_extend(self.av(), idx as libc::ssize_t);
|
||||
|
Loading…
x
Reference in New Issue
Block a user