Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6279
Modified Files: Tag: desiredata s_audio_alsa.c Log Message: fixed dangling pointer in alsa_getdevs
Index: s_audio_alsa.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_audio_alsa.c,v retrieving revision 1.5.4.5.2.2.2.4 retrieving revision 1.5.4.5.2.2.2.5 diff -C2 -d -r1.5.4.5.2.2.2.4 -r1.5.4.5.2.2.2.5 *** s_audio_alsa.c 28 Jun 2007 05:37:53 -0000 1.5.4.5.2.2.2.4 --- s_audio_alsa.c 30 Jun 2007 15:32:20 -0000 1.5.4.5.2.2.2.5 *************** *** 677,703 **** snd_ctl_card_info_t *info; char devname[80]; ! const char *desc; ! if (2 * ndev + 2 > maxndev) ! break; ! /* apparently, "cardno" is just a counter; but check that here */ ! if (ndev != cardno) ! fprintf(stderr, "oops: ALSA cards not reported in order?\n"); ! sprintf(devname, "hw:%d", cardno ); /* fprintf(stderr, "\ntry %s...\n", devname); */ if (snd_ctl_open(&ctl, devname, 0) >= 0) { snd_ctl_card_info_malloc(&info); snd_ctl_card_info(ctl, info); ! desc = snd_ctl_card_info_get_name(info); snd_ctl_card_info_free(info); } else { fprintf(stderr, "ALSA card scan error\n"); ! desc = "???"; } ! /* fprintf(stderr, "name: %s\n", snd_ctl_card_info_get_name(info)); */ ! sprintf(indevlist + 2*ndev * devdescsize, "%s (hardware)", desc); ! sprintf(indevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc); ! sprintf(outdevlist + 2*ndev * devdescsize, "%s (hardware)", desc); ! sprintf(outdevlist + (2*ndev + 1) * devdescsize, "%s (plug-in)", desc); ndev++; } for (i = 0, j = 2*ndev; i < alsa_nnames; i++, j++) { --- 677,702 ---- snd_ctl_card_info_t *info; char devname[80]; ! char *desc; ! if (2 * ndev + 2 > maxndev) break; ! /* apparently, "cardno" is just a counter; but check that here */ ! if (ndev != cardno) fprintf(stderr, "oops: ALSA cards not reported in order?\n"); ! sprintf(devname, "hw:%d", cardno); /* fprintf(stderr, "\ntry %s...\n", devname); */ if (snd_ctl_open(&ctl, devname, 0) >= 0) { snd_ctl_card_info_malloc(&info); snd_ctl_card_info(ctl, info); ! desc = strdup(snd_ctl_card_info_get_name(info)); snd_ctl_card_info_free(info); } else { fprintf(stderr, "ALSA card scan error\n"); ! desc = strdup("???"); } ! fprintf(stderr, "name: %s\n", desc); ! sprintf(indevlist + 2*ndev * devdescsize, "%s (hardware)", desc); ! sprintf(indevlist + (2*ndev+1) * devdescsize, "%s (plug-in)", desc); ! sprintf(outdevlist + 2*ndev * devdescsize, "%s (hardware)", desc); ! sprintf(outdevlist + (2*ndev+1) * devdescsize, "%s (plug-in)", desc); ndev++; + free(desc); } for (i = 0, j = 2*ndev; i < alsa_nnames; i++, j++) {