[vlc-devel] commit: Fix one potential memleak (CID 195) ( Rémi Duraffort )
git version control
git at videolan.org
Sun Oct 5 15:38:21 CEST 2008
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Oct 5 15:31:06 2008 +0200| [1497a8a8616599a33c8db3beead5028d3174fff4] | committer: Rémi Duraffort
Fix one potential memleak (CID 195)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1497a8a8616599a33c8db3beead5028d3174fff4
---
src/modules/entry.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/modules/entry.c b/src/modules/entry.c
index 9a99abb..860efb7 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -453,10 +453,6 @@ int vlc_config_set (module_config_t *restrict item, int id, ...)
{
const char *domain = va_arg (ap, const char *);
size_t len = va_arg (ap, size_t);
- char **dtext = malloc (sizeof (char *) * (len + 1));
-
- if (dtext == NULL)
- break;
/* Copy values */
if (IsConfigIntegerType (item->i_type))
@@ -510,18 +506,19 @@ int vlc_config_set (module_config_t *restrict item, int id, ...)
const char *const *text = va_arg (ap, const char *const *);
if (text != NULL)
{
- for (size_t i = 0; i < len; i++)
- dtext[i] =
- text[i] ? strdup (dgettext (domain, text[i])) : NULL;
-
- dtext[len] = NULL;
+ char **dtext = malloc (sizeof (char *) * (len + 1));
+ if( dtext != NULL )
+ {
+ for (size_t i = 0; i < len; i++)
+ dtext[i] = text[i] ?
+ strdup( dgettext( domain, text[i] ) ) :
+ NULL;
+ dtext[len] = NULL;
+ }
item->ppsz_list_text = dtext;
}
else
- {
- free (dtext);
item->ppsz_list_text = NULL;
- }
item->i_list = len;
item->pf_update_list = va_arg (ap, vlc_callback_t);
More information about the vlc-devel
mailing list