mirror of
https://github.com/X11Libre/xf86-input-libinput.git
synced 2026-04-14 10:54:17 +00:00
(!69) util-strings: don't crash the Xserver on memory alloc failure
It's only consumer already properly checking for NULL return value, so can directly use calloc() here, instead of zalloc() which is crashing the Xserver. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -122,7 +122,9 @@ strv_from_string(const char *in, const char *separators, size_t *num_elements)
|
||||
}
|
||||
|
||||
size_t strv_len = nelems + 1; /* NULL-terminated */
|
||||
char **strv = zalloc(strv_len * sizeof *strv);
|
||||
char **strv = calloc(strv_len, sizeof(*strv));
|
||||
if (!strv)
|
||||
return NULL;
|
||||
|
||||
size_t idx = 0;
|
||||
const char *word;
|
||||
|
||||
@@ -253,7 +253,10 @@ double_array_from_string(const char *in,
|
||||
if(!strv)
|
||||
return result;
|
||||
|
||||
double *numv = zalloc(sizeof(double) * nelem);
|
||||
double *numv = calloc(nelem, sizeof(double));
|
||||
if (!numv)
|
||||
goto out;
|
||||
|
||||
for (size_t idx = 0; idx < nelem; idx++) {
|
||||
double val;
|
||||
if (!safe_atod(strv[idx], &val))
|
||||
|
||||
Reference in New Issue
Block a user