]> git.sesse.net Git - mlt/commitdiff
mlt_frame_get_waveform(): handle memory allocation failure
authorMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 25 Jul 2012 10:08:34 +0000 (12:08 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 25 Jul 2012 22:17:55 +0000 (00:17 +0200)
Fixes Coverity CID 709347.

At conditional (1): "bitmap != NULL" taking the false branch.
CID 709347: Dereference after null check (FORWARD_NULL)
Comparing "bitmap" to null implies that "bitmap" might be null.
 802        if ( bitmap != NULL )
 803                memset( bitmap, 0, size );
 804        mlt_properties_set_data( properties, "waveform", bitmap, size, ( mlt_destructor )mlt_pool_release, NULL );
...
 826                        // Position buffer pointer using y coordinate, stride, and x coordinate
Assigning null: "p" = "bitmap + i / skip + displacement * w".
 827                        unsigned char *p = bitmap + i / skip + displacement * w;
...
 831                                if ( *pcm < 0 )
Dereferencing null variable "p".
 832                                        p[ w * k ] = ( k == 0 ) ? 0xFF : p[ w * k ] + gray;
 833                                else
Dereferencing null variable "p".
 834                                        p[ w * k ] = ( k == height ) ? 0xFF : p[ w * k ] + gray;

src/framework/mlt_frame.c

index 893be3d08c0493ec0fb7cc62eb6af6cf7143ad2b..d1e0373654ec8d70d6ae68ad3031237203354712 100644 (file)
@@ -801,6 +801,8 @@ unsigned char *mlt_frame_get_waveform( mlt_frame self, int w, int h )
        unsigned char *bitmap = ( unsigned char* )mlt_pool_alloc( size );
        if ( bitmap != NULL )
                memset( bitmap, 0, size );
+       else
+               return NULL;
        mlt_properties_set_data( properties, "waveform", bitmap, size, ( mlt_destructor )mlt_pool_release, NULL );
 
        // Render vertical lines