提交 c86827a2 编写于 作者: E Eric Blake

util: plug memory leak

Leak detected by Coverity; only possible on unlikely ptsname_r
failure.  Additionally, the man page for ptsname_r states that
failure is merely non-zero, not necessarily -1.

* src/util/util.c (virFileOpenTtyAt): Avoid leak on ptsname_r
failure.
上级 d69b79ab
......@@ -1126,9 +1126,11 @@ int virFileOpenTtyAt(const char *ptmx,
goto cleanup;
}
if (ptsname_r(*ttymaster, *ttyName, PATH_MAX) < 0)
if (ptsname_r(*ttymaster, *ttyName, PATH_MAX) != 0) {
VIR_FREE(*ttyName);
goto cleanup;
}
}
rc = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册