[Mplayer-cvslog] CVS: main/libao2 audio_out.c,1.42,1.43

Reimar Döffinger CVS syncmail at mplayerhq.hu
Wed Oct 13 18:23:01 CEST 2004


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv22191/libao2

Modified Files:
	audio_out.c 
Log Message:
fixed small memleaks


Index: audio_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- audio_out.c	4 Oct 2004 15:10:32 -0000	1.42
+++ audio_out.c	13 Oct 2004 16:22:57 -0000	1.43
@@ -137,20 +137,26 @@
     // first try the preferred drivers, with their optional subdevice param:
     if(ao_list && ao_list[0])
       while(ao_list[0][0]){
-        char* ao=strdup(ao_list[0]);
+        char* ao=ao_list[0];
+        int ao_len;
         if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) {
           mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
-          free(ao);
           exit_player(NULL);
         }
+        if (ao_subdevice) {
+          free(ao_subdevice);
+          ao_subdevice = NULL;
+        }
 	ao_subdevice=strchr(ao,':');
 	if(ao_subdevice){
-	    ao_subdevice[0]=0;
-	    ++ao_subdevice;
+	    ao_len = ao_subdevice - ao;
+	    ao_subdevice = strdup(&ao[ao_len + 1]);
 	}
+	else
+	    ao_len = strlen(ao);
 	for(i=0;audio_out_drivers[i];i++){
 	    ao_functions_t* audio_out=audio_out_drivers[i];
-	    if(!strcmp(audio_out->info->short_name,ao)){
+	    if(!strncmp(audio_out->info->short_name,ao,ao_len)){
 		// name matches, try it
 		if(use_plugin){
 		    audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out);
@@ -161,12 +167,14 @@
 	    }
 	}
         // continue...
-	free(ao);
 	++ao_list;
 	if(!(ao_list[0])) return NULL; // do NOT fallback to others
       }
+    if (ao_subdevice) {
+      free(ao_subdevice);
+      ao_subdevice = NULL;
+    }
     // now try the rest...
-    ao_subdevice=NULL;
     for(i=0;audio_out_drivers[i];i++){
 	ao_functions_t* audio_out=audio_out_drivers[i];
 	if(use_plugin){




More information about the MPlayer-cvslog mailing list