Skip to content
Snippets Groups Projects
Commit f299ee62 authored by Thomas Guillem's avatar Thomas Guillem
Browse files

config: remove usage of abort

parent e29854a8
No related branches found
No related tags found
No related merge requests found
......@@ -360,8 +360,13 @@ ssize_t config_GetIntChoices (vlc_object_t *obj, const char *name,
return cfg->list.i_cb(obj, name, values, texts);
}
int64_t *vals = xmalloc (sizeof (*vals) * count);
char **txts = xmalloc (sizeof (*txts) * count);
int64_t *vals = malloc (sizeof (*vals) * count);
char **txts = malloc (sizeof (*txts) * count);
if (vals == NULL || txts == NULL)
{
errno = ENOMEM;
goto error;
}
for (size_t i = 0; i < count; i++)
{
......@@ -370,12 +375,22 @@ ssize_t config_GetIntChoices (vlc_object_t *obj, const char *name,
txts[i] = strdup ((cfg->list_text[i] != NULL)
? vlc_gettext (cfg->list_text[i]) : "");
if (unlikely(txts[i] == NULL))
abort ();
{
for (int j = i - 1; j >= 0; --j)
free(txts[j]);
errno = ENOMEM;
goto error;
}
}
*values = vals;
*texts = txts;
return count;
error:
free(vals);
free(txts);
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment