producer_inigo.c: bugfix segfault on unchecked pointer
[melted] / src / modules / inigo / producer_inigo.c
index 1970f9c..88ea2a5 100644 (file)
@@ -24,9 +24,9 @@
 
 #include <framework/mlt.h>
 
-mlt_producer producer_inigo_init( mlt_profile profile, char **argv );
+mlt_producer producer_inigo_init( mlt_profile profile, mlt_service_type type, const char *id, char **argv );
 
-mlt_producer producer_inigo_file_init( mlt_profile profile, char *file )
+mlt_producer producer_inigo_file_init( mlt_profile profile, mlt_service_type type, const char *id, char *file )
 {
        FILE *input = fopen( file, "r" );
        char **args = calloc( sizeof( char * ), 1000 );
@@ -43,7 +43,7 @@ mlt_producer producer_inigo_file_init( mlt_profile profile, char *file )
                }
        }
 
-       mlt_producer result = producer_inigo_init( profile, args );
+       mlt_producer result = producer_inigo_init( profile, type, id, args );
 
        if ( result != NULL )
        {
@@ -120,7 +120,7 @@ static mlt_transition create_transition( mlt_profile profile, mlt_field field, c
        return transition;
 }
 
-mlt_producer producer_inigo_init( mlt_profile profile, char **argv )
+mlt_producer producer_inigo_init( mlt_profile profile, mlt_service_type type, const char *id, char **argv )
 {
        int i;
        int track = 0;
@@ -142,6 +142,7 @@ mlt_producer producer_inigo_init( mlt_profile profile, char **argv )
        mlt_properties_set_int( field_properties, "registered", 0 );
 
        // Parse the arguments
+       if ( argv )
        for ( i = 0; argv[ i ] != NULL; i ++ )
        {
                if ( !strcmp( argv[ i ], "-group" ) )
@@ -402,20 +403,29 @@ mlt_producer producer_inigo_init( mlt_profile profile, char **argv )
                                properties = MLT_PRODUCER_PROPERTIES( producer );
                                mlt_properties_inherit( properties, group );
                        }
+                       else
+                       {
+                               fprintf( stderr, "Failed to load \"%s\"\n", argv[ i ] );
+                       }
                }
                else
                {
-                       if ( !strcmp( argv[ i ], "-serialise" ) )
-                               i += 2;
-                       else if ( !strcmp( argv[ i ], "-consumer" ) )
-                               i += 2;
-                       else if ( !strcmp( argv[ i ], "-profile" ) )
+                       int backtrack = 0;
+                       if ( !strcmp( argv[ i ], "-serialise" ) ||
+                            !strcmp( argv[ i ], "-consumer" ) ||
+                            !strcmp( argv[ i ], "-profile" ) )
+                       {
                                i += 2;
+                               backtrack = 1;
+                       }
 
                        while ( argv[ i ] != NULL && strchr( argv[ i ], '=' ) )
+                       {
                                i ++;
-
-                       i --;
+                               backtrack = 1;
+                       }
+                       if ( backtrack )
+                               i --;
                }
        }