[pbs-devel] [PATCH perlmod] array: avoid underflow when array is empty and more is zero

Fabian Ebner f.ebner at proxmox.com
Thu Feb 18 13:47:43 CET 2021


serializing an empty array triggered this.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 perlmod/src/array.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/perlmod/src/array.rs b/perlmod/src/array.rs
index ce6e112..f0bce57 100644
--- a/perlmod/src/array.rs
+++ b/perlmod/src/array.rs
@@ -102,6 +102,7 @@ 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);
-- 
2.20.1






More information about the pbs-devel mailing list