diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 8df9790f1..171f49c97 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -359,7 +359,6 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property, { RRPropertyPtr prop = RRQueryOutputProperty(output, property); Bool add = FALSE; - INT32 *new_values; if (!prop) { prop = RRCreateOutputProperty(property); @@ -379,14 +378,17 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property, return BadMatch; } - new_values = xallocarray(num_values, sizeof(INT32)); - if (!new_values && num_values) { - if (add) - RRDestroyOutputProperty(prop); - return BadAlloc; - } - if (num_values) + INT32 *new_values = NULL; + + if (num_values) { + new_values = calloc(num_values, sizeof(INT32)); + if (!new_values) { + if (add) + RRDestroyOutputProperty(prop); + return BadAlloc; + } memcpy(new_values, values, num_values * sizeof(INT32)); + } /* * Property moving from pending to non-pending diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index 23a105c02..ea3065b8f 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -327,7 +327,6 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property, { RRPropertyPtr prop = RRQueryProviderProperty(provider, property); Bool add = FALSE; - INT32 *new_values; if (!prop) { prop = RRCreateProviderProperty(property); @@ -347,14 +346,16 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property, return BadMatch; } - new_values = xallocarray(num_values, sizeof(INT32)); - if (!new_values && num_values) { - if (add) - RRDestroyProviderProperty(prop); - return BadAlloc; - } - if (num_values) + INT32 *new_values = NULL; + if (num_values) { + new_values = calloc(num_values, sizeof(INT32)); + if (!new_values) { + if (add) + RRDestroyProviderProperty(prop); + return BadAlloc; + } memcpy(new_values, values, num_values * sizeof(INT32)); + } /* * Property moving from pending to non-pending