From cf24f8952ba9589337053b7e68f3c9548feab956 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Fri, 31 Oct 2003 17:28:05 +0000 Subject: =?UTF-8?q?ip=20=3D=3D=20NULL=20would=20result=20in=20a=20file=20d?= =?UTF-8?q?escriptor=20leak=20(cdda=5Fopen()=20would=20still=20open=20the?= =?UTF-8?q?=20device=20with,=20but=20cdda=5Fclose()=20would=20not=20close?= =?UTF-8?q?=20it)=20so=20we=20provide=20a=20dummy=20instance,=20in=20case?= =?UTF-8?q?=20there=20is=20none=20yet=20(problem=20reported=20by=20Andre?= =?UTF-8?q?=20Maa=C3=9Fdorf)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CVS patchset: 5651 CVS date: 2003/10/31 17:28:05 --- src/input/input_cdda.c | 15 +++++++++++++-- 1 file 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; } -- cgit v1.2.3