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.
This commit is contained in:
Eric Blake 2011-08-02 16:21:37 -06:00
parent d69b79ab72
commit c86827a243

View File

@ -1126,8 +1126,10 @@ 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;