xv: fix double free in AddResource failure case

XvdiDestroyVideoNotifyList already frees the list if AddResource fails,
so don't do it twice.  And set tpn->client to NULL explicitly to avoid
confusing uninitialized memory with a valid value.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
Julien Cristau 2016-03-01 21:39:01 +01:00 committed by Adam Jackson
parent 05e1bcf56e
commit 939ce0bae6

View File

@ -800,10 +800,9 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
return BadAlloc;
tpn->next = NULL;
if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn)) {
free(tpn);
tpn->client = NULL;
if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn))
return BadAlloc;
}
}
else {
/* LOOK TO SEE IF ENTRY ALREADY EXISTS */