mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virSysinfoParseX86BaseBoard: Free memory upfront if no board detected
If no board was detected then VIR_REALLOC_N() done at the end of the function will actually free the memory (because nborads == 0), but @boards will be set to a non-NULL pointer. This makes it unnecessary harder for a caller to see if any board was detected. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c57b205ccf
commit
ac10f838f9
@ -844,8 +844,12 @@ virSysinfoParseX86BaseBoard(const char *base,
|
||||
nboards--;
|
||||
}
|
||||
|
||||
/* This is safe, as we can be only shrinking the memory */
|
||||
ignore_value(VIR_REALLOC_N(boards, nboards));
|
||||
if (nboards == 0) {
|
||||
VIR_FREE(boards);
|
||||
} else {
|
||||
/* This is safe, as we can be only shrinking the memory */
|
||||
ignore_value(VIR_REALLOC_N(boards, nboards));
|
||||
}
|
||||
|
||||
*baseBoard = boards;
|
||||
*nbaseBoard = nboards;
|
||||
|
Loading…
Reference in New Issue
Block a user