diff options
author | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2002-11-02 00:36:03 +0000 |
---|---|---|
committer | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2002-11-02 00:36:03 +0000 |
commit | 4f571fcc3f2cf962105188ffab580f140453c74a (patch) | |
tree | a6d0ead5944721814cc51777dfb0961da2234695 | |
parent | 3617902e6cdfb42c90c431dd0d90fd13c2bc29b8 (diff) | |
download | xine-lib-4f571fcc3f2cf962105188ffab580f140453c74a.tar.gz xine-lib-4f571fcc3f2cf962105188ffab580f140453c74a.tar.bz2 |
Fix xine_get_file_extensions() multi segfaults.
CVS patchset: 3131
CVS date: 2002/11/02 00:36:03
-rw-r--r-- | src/xine-engine/load_plugins.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index a6688dd09..6401152db 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: load_plugins.c,v 1.109 2002/11/01 17:48:18 mroi Exp $ + * $Id: load_plugins.c,v 1.110 2002/11/02 00:36:03 f1rmb Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -1346,34 +1346,43 @@ char *xine_get_file_extensions (xine_t *self) { /* calc length of output */ - len = 0; node = xine_list_first_content (catalog->demux); + len = 0; + node = xine_list_first_content (catalog->demux); while (node) { demux_class_t *cls = (demux_class_t *)node->plugin_class; + char *exts; - len += strlen(cls->get_extensions (cls))+1; + if((exts = cls->get_extensions(cls)) != NULL) + len += strlen(exts) + 1; node = xine_list_next_content (catalog->demux); } /* create output */ - - str = malloc (len+1); + str = malloc (len); /* '\0' space is already counted in the previous loop */ pos = 0; node = xine_list_first_content (catalog->demux); while (node) { demux_class_t *cls = (demux_class_t *)node->plugin_class; - char *e; - int l; + char *e; + int l; - e = cls->get_extensions (cls); - l = strlen(e); - memcpy (&str[pos], e, l); + if((e = cls->get_extensions (cls)) != NULL) { + l = strlen(e); + memcpy (&str[pos], e, l); + + pos += l; + + /* Don't add ' ' char at the end of str */ + if((pos + 1) < len) { + str[pos] = ' '; + pos++; + } + } + node = xine_list_next_content (catalog->demux); - pos += l; - str[pos] = ' '; - pos++; } str[pos] = 0; |