mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
virNetDevBandwidthEqual: Make it more robust
So far the virNetDevBandwidthEqual() expected both ->in and ->out items
to be allocated for both @a and @b compared. This is not necessary true
for all our code. For instance, running 'update-device' twice over a NIC
with the very same XML results in SIGSEGV-ing in this function.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ee02fbc8e4
)
This commit is contained in:
parent
17d50d49af
commit
0e20cc86b8
@ -335,16 +335,30 @@ virNetDevBandwidthEqual(virNetDevBandwidthPtr a,
|
||||
return false;
|
||||
|
||||
/* in */
|
||||
if (a->in->average != b->in->average ||
|
||||
a->in->peak != b->in->peak ||
|
||||
a->in->burst != b->in->burst)
|
||||
if (a->in) {
|
||||
if (!b->in)
|
||||
return false;
|
||||
|
||||
if (a->in->average != b->in->average ||
|
||||
a->in->peak != b->in->peak ||
|
||||
a->in->burst != b->in->burst)
|
||||
return false;
|
||||
} else if (b->in) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*out*/
|
||||
if (a->out->average != b->out->average ||
|
||||
a->out->peak != b->out->peak ||
|
||||
a->out->burst != b->out->burst)
|
||||
if (a->out) {
|
||||
if (!b->out)
|
||||
return false;
|
||||
|
||||
if (a->out->average != b->out->average ||
|
||||
a->out->peak != b->out->peak ||
|
||||
a->out->burst != b->out->burst)
|
||||
return false;
|
||||
} else if (b->out) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user