mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +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;
|
||||
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) {
|
||||
virReportOOMError();
|
||||
@ -1169,7 +1170,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
|
||||
if (virMutexInit(&sess->lock) < 0) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Failed to initialized mutex"));
|
||||
VIR_FREE(ctxt);
|
||||
VIR_FREE(sess);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user