[vlc-commits] config: remove usage of abort
Thomas Guillem
git at videolan.org
Sun Jun 5 17:15:22 CEST 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sun Jun 5 17:14:44 2016 +0200| [f299ee62a46414da3269085e90f257a1d6d54012] | committer: Thomas Guillem
config: remove usage of abort
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f299ee62a46414da3269085e90f257a1d6d54012
---
src/config/core.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/config/core.c b/src/config/core.c
index 322b5f0..67a3526 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -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;
}
More information about the vlc-commits
mailing list