]> git.sesse.net Git - vlc/commitdiff
Remove unneeded msg_Err.
authorRémi Duraffort <ivoire@videolan.org>
Sun, 22 Jun 2008 20:05:09 +0000 (22:05 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Sun, 22 Jun 2008 20:05:09 +0000 (22:05 +0200)
Fix potential segfault (check malloc return value).

25 files changed:
modules/audio_output/alsa.c
modules/audio_output/arts.c
modules/audio_output/auhal.c
modules/audio_output/directx.c
modules/audio_output/esd.c
modules/audio_output/file.c
modules/audio_output/hd1000a.cpp
modules/audio_output/jack.c
modules/audio_output/oss.c
modules/audio_output/portaudio.c
modules/audio_output/waveout.c
modules/codec/avcodec/audio.c
modules/codec/avcodec/deinterlace.c
modules/codec/avcodec/encoder.c
modules/codec/avcodec/video.c
modules/codec/cmml/cmml.c
modules/codec/dmo/dmo.c
modules/codec/dvbsub.c
modules/codec/subtitles/subsdec.c
modules/codec/subtitles/subsusf.c
modules/demux/avi/avi.c
modules/demux/mjpeg.c
modules/demux/playlist/xspf.c
modules/demux/subtitle.c
modules/demux/subtitle_asa.c

index c6d7a58d99e09ddb1a6ca91850816236c6ec0c89..5a2916fb47bc8978744e1006af73c1f9c92685fe 100644 (file)
@@ -313,10 +313,7 @@ static int Open( vlc_object_t *p_this )
     /* Allocate structures */
     p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
     p_sys->b_playing = false;
     p_sys->start_date = 0;
     vlc_cond_init( p_aout, &p_sys->wait );
index ef4b2617bdcf42db2342ec4a227ed1ccb03f7411..525787d5818a0bf2b7e15a8ab2b5aa1fe8045531 100644 (file)
@@ -83,10 +83,7 @@ static int Open( vlc_object_t *p_this )
     /* Allocate structure */
     p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
     p_aout->output.p_sys = p_sys;
 
     i_err = arts_init();
index 7ef69e220aa9c613360609ac0dd3fd654493547e..067144950a51eb50b947e4a3ee8d24f1946c0440 100644 (file)
@@ -161,10 +161,7 @@ static int Open( vlc_object_t * p_this )
     /* Allocate structure */
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
-        return( VLC_ENOMEM );
-    }
+        return VLC_ENOMEM;
 
     p_sys = p_aout->output.p_sys;
     p_sys->i_default_dev = 0;
@@ -649,10 +646,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
     i_streams = i_param_size / sizeof( AudioStreamID );
     p_streams = (AudioStreamID *)malloc( i_param_size );
     if( p_streams == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return false;
-    }
  
     err = AudioDeviceGetProperty( p_sys->i_selected_dev, 0, FALSE,
                                     kAudioDevicePropertyStreams,
@@ -685,10 +679,7 @@ static int OpenSPDIF( aout_instance_t * p_aout )
         i_formats = i_param_size / sizeof( AudioStreamBasicDescription );
         p_format_list = (AudioStreamBasicDescription *)malloc( i_param_size );
         if( p_format_list == NULL )
-        {
-            msg_Err( p_aout, "could not malloc the memory" );
             continue;
-        }
  
         err = AudioStreamGetProperty( p_streams[i], 0,
                                           kAudioStreamPropertyPhysicalFormats,
@@ -951,10 +942,7 @@ static void Probe( aout_instance_t * p_aout )
     /* Allocate DeviceID array */
     p_devices = (AudioDeviceID*)malloc( sizeof(AudioDeviceID) * p_sys->i_devices );
     if( p_devices == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         goto error;
-    }
 
     /* Populate DeviceID array */
     err = AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
@@ -1101,10 +1089,7 @@ static int AudioDeviceSupportsDigital( aout_instance_t *p_aout, AudioDeviceID i_
     i_streams = i_param_size / sizeof( AudioStreamID );
     p_streams = (AudioStreamID *)malloc( i_param_size );
     if( p_streams == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
  
     err = AudioDeviceGetProperty( i_dev_id, 0, FALSE,
                                     kAudioDevicePropertyStreams,
@@ -1150,10 +1135,7 @@ static int AudioStreamSupportsDigital( aout_instance_t *p_aout, AudioStreamID i_
     i_formats = i_param_size / sizeof( AudioStreamBasicDescription );
     p_format_list = (AudioStreamBasicDescription *)malloc( i_param_size );
     if( p_format_list == NULL )
-    {
-        msg_Err( p_aout, "could not malloc the memory" );
         return false;
-    }
  
     err = AudioStreamGetProperty( i_stream_id, 0,
                                       kAudioStreamPropertyPhysicalFormats,
index 9df65151db1c696696cb6083ab8891146f9fbe44..787bc3c142d35f4ec1d520d415cce1ae2de0a7a0 100644 (file)
@@ -254,10 +254,7 @@ static int OpenAudio( vlc_object_t *p_this )
    /* Allocate structure */
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     /* Initialize some variables */
     p_aout->output.p_sys->p_dsobject = NULL;
index e844d14a6af55cb26ef10a0527ab5c84364dce7b..d42940e6d7ea31057b14a3c32ac41f90f75f4706 100644 (file)
@@ -91,10 +91,7 @@ static int Open( vlc_object_t *p_this )
     /* Allocate structure */
     p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     p_aout->output.p_sys = p_sys;
 
index e2251c4b1aad48b7f3dc884228160183cb0588ea..c8af6f5f9085db382f3fde07644be8847dc051b2 100644 (file)
@@ -154,10 +154,7 @@ static int Open( vlc_object_t * p_this )
     /* Allocate structure */
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     if( !strcmp( psz_name, "-" ) )
         p_aout->output.p_sys->p_file = stdout;
index 5e81ae742647d365cacc65f891306f60320cbd4a..c111c2a6d12e7c8d9593f20bd717db0c0733e087 100644 (file)
@@ -97,18 +97,14 @@ static int Open( vlc_object_t * p_this )
     p_aout->output.p_sys = p_sys =
         (aout_sys_t *)malloc( sizeof( aout_sys_t ) );
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     /* New PCMAudioPlayer */
     p_sys->pPlayer = pPlayer = new PCMAudioPlayer();
     if( p_sys->pPlayer == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         free( p_sys );
-        return VLC_EGENERIC;
+        return VLC_ENOMEM;
     }
 
     /* Get Buffer Requirements */
@@ -127,10 +123,9 @@ static int Open( vlc_object_t * p_this )
     p_sys->ppBuffers = (void **)malloc( p_sys->nBuffers * sizeof( void * ) );
     if( p_sys->ppBuffers == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         delete pPlayer;
         free( p_sys );
-        return VLC_EGENERIC;
+        return VLC_ENOMEM;
     }
 
     /* Open PCMAudioPlayer */
index 7fb409bb2410adce6ab4348ee60f4d2d2e40609f..c8345db4a0e325757bc0ec64a0a8179c662c8b81 100644 (file)
@@ -108,7 +108,6 @@ static int Open( vlc_object_t *p_this )
     p_sys = calloc( 1, sizeof( aout_sys_t ) );
     if( p_sys == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         status = VLC_ENOMEM;
         goto error_out;
     }
@@ -143,7 +142,6 @@ static int Open( vlc_object_t *p_this )
                                   sizeof(jack_port_t *) );
     if( p_sys->p_jack_ports == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         status = VLC_ENOMEM;
         goto error_out;
     }
@@ -152,7 +150,6 @@ static int Open( vlc_object_t *p_this )
                                     sizeof(jack_sample_t *) );
     if( p_sys->p_jack_buffers == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         status = VLC_ENOMEM;
         goto error_out;
     }
index 2ea467b3b626d98d06ce1cb4bd5630776d191b55..db1e28e63ec12d0672ee0cfd0f40d85dc1ea35c8 100644 (file)
@@ -279,10 +279,7 @@ static int Open( vlc_object_t *p_this )
     /* Allocate structure */
     p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     /* Get device name */
     if( (psz_device = config_GetPsz( p_aout, "dspdev" )) == NULL )
index 7c1d256baa858aaf8f940b261d5cf230e706aa5e..4e382dd593641177d9fb85be78ef24137047baae 100644 (file)
@@ -181,10 +181,7 @@ static int Open( vlc_object_t * p_this )
     /* Allocate p_sys structure */
     p_sys = (aout_sys_t *)malloc( sizeof(aout_sys_t) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
     p_sys->p_aout = p_aout;
     p_sys->p_stream = 0;
     p_aout->output.p_sys = p_sys;
index 2a57e01a558644006fc10abc30c6ca5517bfecbc..8ca55d83327674a38236de93483836783700bedf 100644 (file)
@@ -245,10 +245,7 @@ static int Open( vlc_object_t *p_this )
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
 
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     p_aout->output.pf_play = Play;
     p_aout->b_die = false;
@@ -411,7 +408,6 @@ static int Open( vlc_object_t *p_this )
     if( p_aout->output.p_sys->p_silence_buffer == NULL )
     {
         free( p_aout->output.p_sys );
-        msg_Err( p_aout, "out of memory" );
         return 1;
     }
     p_aout->output.p_sys->i_repeat_counter = 0;
index ca48b90b36061353f59ee72fc7fc10e5c2000fd0..40213074ac349438baca44774db4be80eaada732 100644 (file)
@@ -100,7 +100,6 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_dec, "out of memory" );
         return VLC_ENOMEM;
     }
 
@@ -139,12 +138,15 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
         p_sys->p_context->extradata =
             malloc( p_sys->p_context->extradata_size +
                     FF_INPUT_BUFFER_PADDING_SIZE );
-        memcpy( p_sys->p_context->extradata,
-                (char*)p_dec->fmt_in.p_extra + i_offset,
-                p_sys->p_context->extradata_size );
-        memset( (char*)p_sys->p_context->extradata +
-                p_sys->p_context->extradata_size, 0,
-                FF_INPUT_BUFFER_PADDING_SIZE );
+        if( p_sys->p_context->extradata )
+        {
+            memcpy( p_sys->p_context->extradata,
+                    (char*)p_dec->fmt_in.p_extra + i_offset,
+                    p_sys->p_context->extradata_size );
+            memset( (char*)p_sys->p_context->extradata +
+                    p_sys->p_context->extradata_size, 0,
+                    FF_INPUT_BUFFER_PADDING_SIZE );
+        }
     }
     else
         p_sys->p_context->extradata = NULL;
index c9299c2b00d32385440b30f501b3f6e2704456e1..0d6f07ddbcc1aef34243bfe0b3f563ec6eebf87d 100644 (file)
@@ -84,7 +84,6 @@ int OpenDeinterlace( vlc_object_t *p_this )
     if( ( p_filter->p_sys = p_sys =
           (filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL )
     {
-        msg_Err( p_filter, "out of memory" );
         return VLC_EGENERIC;
     }
 
index 3eaa2dcef54c57b1d9e6c3de318bb7cfcc8eeb59..23c2674465ef3a08507432b61864e87f8c713f54 100644 (file)
@@ -253,10 +253,7 @@ int OpenEncoder( vlc_object_t *p_this )
 
     /* Allocate the memory needed to store the encoder's structure */
     if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
-    {
-        msg_Err( p_enc, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
     memset( p_sys, 0, sizeof(encoder_sys_t) );
     p_enc->p_sys = p_sys;
     p_sys->p_codec = p_codec;
index 6dc871317d178c75e2ac856f3599e4c21bec0a18..e1335af46927e038ed9009ee7182be7f2a485575 100644 (file)
@@ -232,7 +232,6 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_dec, "out of memory" );
         return VLC_ENOMEM;
     }
     memset( p_sys, 0, sizeof(decoder_sys_t) );
index a2bd47a1a61e43ce9fbd7c5347bc5d5f1cb0b175..2e5109efcea5c622b55395004ce62890a1fd5516 100644 (file)
@@ -108,7 +108,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_dec, "out of memory" );
         return VLC_EGENERIC;
     }
 
index 48d358de768cad77cc6ed9e41adaa9a6bf3cd01b..55fe6e279f5009a06b1c6b6d807030cdb47c5047 100644 (file)
@@ -520,7 +520,6 @@ static int DecOpen( vlc_object_t *p_this )
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_dec, "out of memory" );
         goto error;
     }
 
@@ -1341,7 +1340,6 @@ static int EncOpen( vlc_object_t *p_this )
     if( ( p_enc->p_sys = p_sys =
           (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_enc, "out of memory" );
         goto error;
     }
 
index 258d01c33afe259afc96e1af7cbe96b9e81a9e00..a56c83d554742804d2d1732d179d9950d75db25f 100644 (file)
@@ -1664,10 +1664,7 @@ static int OpenEncoder( vlc_object_t *p_this )
 
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
-    {
-        msg_Err( p_enc, "out of memory" );
         return VLC_ENOMEM;
-    }
     p_enc->p_sys = p_sys;
 
     p_enc->pf_encode_sub = Encode;
index cfb83a6e3d07d560e2f647c114b7d2f4547b5a05..5d4aaf2f3b6b0ec8ff0382d77db63a556c82b43f 100644 (file)
@@ -160,10 +160,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     p_dec->p_sys = p_sys = malloc( sizeof( *p_sys ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_dec, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     /* init of p_sys */
     memset( p_sys, 0, sizeof( *p_sys ) );
index 657ae4a0378704da8fe10be62c10c01706acfb2e..162cd1d49deff6b6c371964df7a0218675919aaf 100644 (file)
@@ -79,7 +79,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)calloc(1, sizeof(decoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_dec, "out of memory" );
         return VLC_ENOMEM;
     }
 
@@ -400,7 +399,6 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
         p_text_region->psz_html = strndup( psz_subtitle, i_len );
         if( ! p_text_region->psz_html )
         {
-            msg_Err( p_dec, "out of memory" );
             p_spu->pf_destroy_region( VLC_OBJECT(p_dec), p_text_region );
             return NULL;
         }
@@ -649,7 +647,6 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                     p_style = calloc( 1, sizeof(ssa_style_t) );
                     if( ! p_style )
                     {
-                        msg_Err( p_dec, "out of memory" );
                         free( psz_node );
                         break;
                     }
index c3489481d40f78e255bdf71e8eef650338b42caf..723aa0efdab38de562cf8f01d41d77a0f426cea4 100644 (file)
@@ -356,10 +356,7 @@ static int Open( vlc_object_t * p_this )
     {
         avi_track_t           *tk     = malloc( sizeof( avi_track_t ) );
         if( !tk )
-        {
-            msg_Err( p_demux, "Out of memory" );
             goto error;
-        }
 
         avi_chunk_list_t      *p_strl = AVI_ChunkFind( p_hdrl, AVIFOURCC_strl, i );
         avi_chunk_strh_t      *p_strh = AVI_ChunkFind( p_strl, AVIFOURCC_strh, 0 );
index 165b415084f4fa34e96b4b29ec17bf2e95a99e96..f601d92899492c91fd4868f18d158d5033134a98 100644 (file)
@@ -156,11 +156,8 @@ static char* GetLine( demux_t *p_demux, int *p_pos )
         i--;
     }
     p_line = malloc( i + 1 );
-    if( NULL == p_line )
-    {
-        msg_Err( p_demux, "out of memory" );
+    if( p_line == NULL )
         return NULL;
-    }
     strncpy ( p_line, (char*)p_buf, i );
     p_line[i] = '\0';
 //    msg_Dbg( p_demux, "i = %d, pos = %d, %s", i, *p_pos, p_line );
index 0dc77aeaabfcf6a8ded27b012971d524a7bd808a..42c1ed6e0d388007b1250ff1b30d09b1a0594922 100644 (file)
@@ -545,10 +545,7 @@ static bool parse_track_node COMPLEX_INTERFACE
                                    strlen(p_demux->p_sys->psz_base) +
                                    strlen(psz_uri) +1 );
                            if( !psz_tmp )
-                           {
-                               msg_Err( p_demux, "out of memory");
                                return false;
-                           }
                            sprintf( psz_tmp, "%s%s",
                                     p_demux->p_sys->psz_base, psz_uri );
                            free( psz_uri );
index 46f26534bec8b057cc4ce200e853118565a0b0fc..14940862f72182f8d8ffe8c7a7a854b05b7bbed1 100644 (file)
@@ -449,7 +449,6 @@ static int Open ( vlc_object_t *p_this )
             if( !( p_sys->subtitle = realloc( p_sys->subtitle,
                                               sizeof(subtitle_t) * i_max ) ) )
             {
-                msg_Err( p_demux, "out of memory");
                 free( p_sys->subtitle );
                 TextUnload( &p_sys->txt );
                 free( p_sys );
index cd6f4f79ee8afb8bb1a0f416b0c6424b8f85783b..273d8f39f96d756878dc8b71032060dfbe7fa7c8 100644 (file)
@@ -140,6 +140,8 @@ static int Open ( vlc_object_t *p_this )
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
     p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
+    if( !p_sys  )
+        return VLC_ENOMEM;
     p_sys->psz_header         = NULL;
     p_sys->i_subtitle         = 0;
     p_sys->i_subtitles        = 0;
@@ -220,7 +222,6 @@ static int Open ( vlc_object_t *p_this )
     p_data = malloc( i_ssize );
     if( !p_data )
     {
-        msg_Err( p_demux, "out of memory");
         free( p_sys );
         return VLC_ENOMEM;
     }
@@ -281,7 +282,6 @@ static int ProcessLine( demux_t *p_demux, void *p_arg,
         if( !( p_sys->subtitle = realloc( p_sys->subtitle, sizeof(subtitle_t)
                                           * p_sys->i_subs_alloc ) ) )
         {
-            msg_Err( p_demux, "out of memory");
             return VLC_ENOMEM;
         }
     }