diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 2a4e33705..cf4f712bb 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -360,7 +360,6 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property, { RRPropertyPtr prop = RRQueryOutputProperty(output, property); Bool add = FALSE; - INT32 *new_values; if (!prop) { prop = RRCreateOutputProperty(property); @@ -380,14 +379,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 aec86e4d0..11d986b33 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -277,7 +277,6 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property, { RRPropertyPtr prop = RRQueryProviderProperty(provider, property); Bool add = FALSE; - INT32 *new_values; if (!prop) { prop = RRCreateProviderProperty(property); @@ -297,14 +296,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