If AllocGrab() fails to set up grab, don't copy to a NULL grab

If either the initial calloc or the xi2mask_new fails, grab is NULL,
but if a src grab is passed in, it was always being written to by
CopyGrab (and if that failed, dereferenced again in teardown).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Alan Coopersmith 2014-01-06 17:10:38 -08:00 committed by Peter Hutterer
parent 2ea973e12f
commit 3a113815a0

View File

@ -199,12 +199,11 @@ AllocGrab(const GrabPtr src)
free(grab);
grab = NULL;
}
}
if (src && !CopyGrab(grab, src)) {
free(grab->xi2mask);
free(grab);
grab = NULL;
else if (src && !CopyGrab(grab, src)) {
free(grab->xi2mask);
free(grab);
grab = NULL;
}
}
return grab;