mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 22:15:20 +00:00
rpc: avoid crash on error
Detected by Coverity. Freeing the wrong variable results in both a memory leak and the likelihood of the caller dereferencing through a freed pointer. * src/rpc/virnettlscontext.c (virNetTLSSessionNew): Free correct variable.
This commit is contained in:
parent
9160573d32
commit
ed246fbb79
@ -1159,7 +1159,8 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
virNetTLSSessionPtr sess;
|
virNetTLSSessionPtr sess;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
VIR_DEBUG("ctxt=%p hostname=%s isServer=%d", ctxt, NULLSTR(hostname), ctxt->isServer);
|
VIR_DEBUG("ctxt=%p hostname=%s isServer=%d",
|
||||||
|
ctxt, NULLSTR(hostname), ctxt->isServer);
|
||||||
|
|
||||||
if (VIR_ALLOC(sess) < 0) {
|
if (VIR_ALLOC(sess) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -1169,7 +1170,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
|||||||
if (virMutexInit(&sess->lock) < 0) {
|
if (virMutexInit(&sess->lock) < 0) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Failed to initialized mutex"));
|
_("Failed to initialized mutex"));
|
||||||
VIR_FREE(ctxt);
|
VIR_FREE(sess);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user