Update of /cvsroot/alsa/alsa-lib/src/pcm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27606/src/pcm

Modified Files:
        pcm_adpcm.c pcm_direct.c pcm_ladspa.c pcm_multi.c pcm_share.c 
        pcm_shm.c 
Log Message:
- check the return value of malloc & co.




Index: pcm_adpcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_adpcm.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- pcm_adpcm.c 25 Jul 2003 17:02:02 -0000      1.59
+++ pcm_adpcm.c 25 Feb 2004 11:24:29 -0000      1.60
@@ -439,6 +439,8 @@
        }
        assert(!adpcm->states);
        adpcm->states = malloc(adpcm->plug.slave->channels * sizeof(*adpcm->states));
+       if (adpcm->states == NULL)
+               return -ENOMEM;
        return 0;
 }
 

Index: pcm_direct.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_direct.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- pcm_direct.c        9 Feb 2004 17:04:09 -0000       1.16
+++ pcm_direct.c        25 Feb 2004 11:24:30 -0000      1.17
@@ -923,6 +923,8 @@
                return -EINVAL;
        }
        dmix->bindings = malloc(count * sizeof(unsigned int));
+       if (dmix->bindings == NULL)
+               return -ENOMEM;
        for (chn = 0; chn < count; chn++)
                dmix->bindings[chn] = UINT_MAX;         /* don't route */
        snd_config_for_each(i, next, cfg) {

Index: pcm_ladspa.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_ladspa.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- pcm_ladspa.c        25 Jul 2003 17:02:03 -0000      1.15
+++ pcm_ladspa.c        25 Feb 2004 11:24:30 -0000      1.16
@@ -771,6 +771,8 @@
                }
                
                filename = malloc(len + strlen(dirent->d_name) + 1 + need_slash);
+               if (filename == NULL)
+                       return -ENOMEM;
                strcpy(filename, path);
                if (need_slash)
                        strcat(filename, "/");
@@ -880,6 +882,8 @@
                }
                if (count > 0) {
                        array = (unsigned int *)calloc(count, sizeof(unsigned int));
+                       if (! array)
+                               return -ENOMEM;
                        memset(array, 0xff, count * sizeof(unsigned int));
                        io->port_bindings_size = count;
                        io->port_bindings = array;
@@ -928,6 +932,8 @@
                        if ((lplug->desc->PortDescriptors[idx] & (io->pdesc | 
LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL))
                                count++;
                array = (LADSPA_Data *)calloc(count, sizeof(LADSPA_Data));
+               if (!array)
+                       return -ENOMEM;
                io->controls_size = count;
                io->controls = array;
                snd_config_for_each(i, next, controls) {

Index: pcm_multi.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_multi.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- pcm_multi.c 23 Oct 2003 14:42:47 -0000      1.85
+++ pcm_multi.c 25 Feb 2004 11:24:30 -0000      1.86
@@ -696,8 +696,17 @@
        multi->slaves_count = slaves_count;
        multi->master_slave = master_slave;
        multi->slaves = calloc(slaves_count, sizeof(*multi->slaves));
+       if (!multi->slaves) {
+               free(multi);
+               return -ENOMEM;
+       }
        multi->channels_count = channels_count;
        multi->channels = calloc(channels_count, sizeof(*multi->channels));
+       if (!multi->channels) {
+               free(multi->slaves);
+               free(multi->channels);
+               return -ENOMEM;
+       }
        for (i = 0; i < slaves_count; ++i) {
                snd_pcm_multi_slave_t *slave = &multi->slaves[i];
                assert(slaves_pcm[i]->stream == stream);
@@ -914,6 +923,11 @@
        slaves_channels = calloc(slaves_count, sizeof(*slaves_channels));
        channels_sidx = calloc(channels_count, sizeof(*channels_sidx));
        channels_schannel = calloc(channels_count, sizeof(*channels_schannel));
+       if (!slaves_id || !slaves_conf || !slaves_pcm || !slaves_channels ||
+           !channels_sidx || !channels_schannel) {
+               err = -ENOMEM;
+               goto _free;
+       }
        idx = 0;
        for (idx = 0; idx < channels_count; ++idx)
                channels_sidx[idx] = -1;
@@ -1036,6 +1050,8 @@
                free(channels_sidx);
        if (channels_schannel)
                free(channels_schannel);
+       if (slaves_id)
+               free(slaves_id);
        return err;
 }
 #ifndef DOC_HIDDEN

Index: pcm_share.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_share.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- pcm_share.c 23 Oct 2003 14:42:47 -0000      1.77
+++ pcm_share.c 25 Feb 2004 11:24:30 -0000      1.78
@@ -1630,6 +1630,10 @@
                goto _free;
        }
        channels_map = calloc(channels, sizeof(*channels_map));
+       if (! channels_map) {
+               err = -ENOMEM;
+               goto _free;
+       }
 
        snd_config_for_each(i, next, bindings) {
                snd_config_t *n = snd_config_iterator_entry(i);

Index: pcm_shm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_shm.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- pcm_shm.c   25 Jul 2003 17:02:04 -0000      1.58
+++ pcm_shm.c   25 Feb 2004 11:24:30 -0000      1.59
@@ -795,6 +795,8 @@
        
        conf.ifc_len = numreqs * sizeof(struct ifreq);
        conf.ifc_buf = malloc((unsigned int) conf.ifc_len);
+       if (! conf.ifc_buf)
+               return -ENOMEM;
        while (1) {
                err = ioctl(s, SIOCGIFCONF, &conf);
                if (err < 0) {
@@ -806,6 +808,8 @@
                numreqs *= 2;
                conf.ifc_len = numreqs * sizeof(struct ifreq);
                conf.ifc_buf = realloc(conf.ifc_buf, (unsigned int) conf.ifc_len);
+               if (! conf.ifc_buf)
+                       return -ENOMEM;
        }
        numreqs = conf.ifc_len / sizeof(struct ifreq);
        for (i = 0; i < numreqs; ++i) {



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to