XkbAddGeomProperty: Fix checks for malloc failure

Check the variable we just tried to malloc, not the string we're copying
and already checked for NULL at the beginning of the function.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Alan Coopersmith 2011-02-13 21:36:04 -08:00 committed by Peter Hutterer
parent aac1b43566
commit 682865c460

View File

@ -659,11 +659,11 @@ register XkbPropertyPtr prop;
} }
prop= &geom->properties[geom->num_properties]; prop= &geom->properties[geom->num_properties];
prop->name= malloc(strlen(name)+1); prop->name= malloc(strlen(name)+1);
if (!name) if (!prop->name)
return NULL; return NULL;
strcpy(prop->name,name); strcpy(prop->name,name);
prop->value= malloc(strlen(value)+1); prop->value= malloc(strlen(value)+1);
if (!value) { if (!prop->value) {
free(prop->name); free(prop->name);
prop->name= NULL; prop->name= NULL;
return NULL; return NULL;