diff options
author | Michael Roitzsch <mroi@users.sourceforge.net> | 2003-10-31 17:28:05 +0000 |
---|---|---|
committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2003-10-31 17:28:05 +0000 |
commit | cf24f8952ba9589337053b7e68f3c9548feab956 (patch) | |
tree | 1e39603749b600cd0ee343afb09d97ad5597f21b | |
parent | 68fb5107a56d7efcf82a7c8015fbc0f39434f056 (diff) | |
download | xine-lib-cf24f8952ba9589337053b7e68f3c9548feab956.tar.gz xine-lib-cf24f8952ba9589337053b7e68f3c9548feab956.tar.bz2 |
ip == NULL would result in a file descriptor leak
(cdda_open() would still open the device with, but cdda_close() would not close it)
so we provide a dummy instance, in case there is none yet
(problem reported by Andre Maaßdorf)
CVS patchset: 5651
CVS date: 2003/10/31 17:28:05
-rw-r--r-- | src/input/input_cdda.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 648ddb27d..f24950896 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -20,7 +20,7 @@ * Compact Disc Digital Audio (CDDA) Input Plugin * by Mike Melanson (melanson@pcisys.net) * - * $Id: input_cdda.c,v 1.35 2003/09/21 12:29:59 hadess Exp $ + * $Id: input_cdda.c,v 1.36 2003/10/31 17:28:05 mroi Exp $ */ #ifdef HAVE_CONFIG_H @@ -2476,6 +2476,13 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, toc = init_cdrom_toc(); fd = -1; + + if (!ip) + /* we need an instance pointer to store all the details about the + * device we are going to open; but it is possible that this function + * gets called, before a plugin instance has been created; + * let's create a dummy instance in such a condition */ + ip = (cdda_input_plugin_t *)xine_xmalloc(sizeof(cdda_input_plugin_t)); #ifndef WIN32 if( strchr(this->cdda_device,':') ) { @@ -2488,6 +2495,7 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, if (fd == -1) { if (cdda_open(ip, this->cdda_device, toc, &fd) == -1) { + if (ip != this->ip) free(ip); return NULL; } } @@ -2505,8 +2513,10 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, cdda_close(ip); - if ( err < 0 ) + if ( err < 0 ) { + if (ip != this->ip) free(ip); return NULL; + } num_tracks = toc->last_track - toc->first_track; if (toc->ignore_last_track) @@ -2519,6 +2529,7 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, *num_files = toc->last_track - toc->first_track + 1; free_cdrom_toc(toc); + if (ip != this->ip) free(ip); return this->autoplaylist; } |