autoupdater: Replace malloc by safe_malloc

During argument parsing the allocation of the string array for
the mirror list had no NULL check leading to a possible null ptr
dereference

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
This commit is contained in:
Tobias Schramm 2018-02-20 12:17:49 +01:00
parent a6336d0bce
commit 5f65095e47
1 changed files with 2 additions and 1 deletions

View File

@ -144,7 +144,8 @@ static void parse_args(int argc, char *argv[], struct settings *settings) {
if (optind < argc) {
settings->n_mirrors = argc - optind;
settings->mirrors = malloc(settings->n_mirrors * sizeof(char *));
settings->mirrors = safe_malloc(settings->n_mirrors * sizeof(char *), "failed to allocate memory for mirror list");
for (int i = optind; i < argc; i++) {
settings->mirrors[i - optind] = argv[i];
}