From the manpage of asprintf:
"If memory allocation wasn't possible, or some other error occurs,
these functions will return -1, and the contents of strp are
undefined."
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
return NULL;
}
- asprintf(&filename, "%s/%s", dir_path, entry->d_name);
+ if (asprintf(&filename, "%s/%s", dir_path, entry->d_name) < 0)
+ filename = NULL;
closedir(dir);
a = rand() % 16;
b = rand() % 16;
- asprintf (&dir_path, "%s/%c%c", cache->path, hex[a], hex[b]);
- if (dir_path == NULL)
+ if (asprintf(&dir_path, "%s/%c%c", cache->path, hex[a], hex[b]) < 0)
return;
size = unlink_random_file_from_directory(dir_path);