vppinfra: keep AddressSanitizer happy 51/38051/2
authorBenoît Ganne <bganne@cisco.com>
Thu, 26 Jan 2023 18:23:19 +0000 (19:23 +0100)
committerDamjan Marion <dmarion@0xa5.net>
Mon, 30 Jan 2023 18:18:14 +0000 (18:18 +0000)
The vector size must be increased before setting the element so that
AddressSanitizer can keep track of the accessible memory.

Type: fix

Change-Id: I7b13ce98ff29d98e643f399ec1ecb4681d3cec92
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vppinfra/pool.h

index ef81609..ea22af4 100644 (file)
@@ -295,8 +295,9 @@ _pool_put_index (void *p, uword index, uword elt_sz)
   /* Preallocated pool? */
   if (ph->max_elts)
     {
-      ph->free_indices[_vec_len (ph->free_indices)] = index;
-      vec_inc_len (ph->free_indices, 1);
+      u32 len = _vec_len (ph->free_indices);
+      vec_set_len (ph->free_indices, len + 1);
+      ph->free_indices[len] = index;
     }
   else
     vec_add1 (ph->free_indices, index);