diff options
author | Steven Luong <sluong@cisco.com> | 2020-05-08 04:50:05 -0700 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-08-18 09:54:56 +0000 |
commit | 704a2c452eeba652221a20e094606a74a0ff4f2b (patch) | |
tree | 389d645a739211442f12410c521e49de6666513b /src/vlib/trace.h | |
parent | 4cdca2fc20f2da23ece3b3ae711bcb53ef767799 (diff) |
vppinfra: set explicit found in search_free_list loop
While https://gerrit.fd.io/r/c/vpp/+/26948 fixed avoid using -1 to
index into h->free_lists[b][l] by changing the loop counter, the
check for the value of the loop counter (l < 0) cannot be trusted
to decide whether we've found a large enough object within the bin
or not. When the loop is terminated, the value of the variable l
could be ambiguous if it equals to 0 and it is never less than 0,
ie, when we bail out of the loop, we don't know if it was due to the
breaking out of the condition in
if ((s = f_size - size) >= 0)
break;
or
while (l > 0);
The fix is to explicitly set a variable when we have found a large enough
object inside the loop to be used to test whether the loop was prematurely
terminated (found == 1) or the loop just ran exhausted (found == 0)
Type: fix
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I0161813fbd44dcba8982a767eac2e0930e9d77e3
(cherry picked from commit a5436ae2516edc955f26c6aa4103f5946ee8653c)
Diffstat (limited to 'src/vlib/trace.h')
0 files changed, 0 insertions, 0 deletions