提交 ac10f838 编写于 作者: M Michal Privoznik

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: NMichal Privoznik <mprivozn@redhat.com>
上级 c57b205c
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册