Changeset 1273

Show
Ignore:
Timestamp:
12/09/07 16:35:55 (1 year ago)
Author:
perry
Message:

Don't crash when destroying an output trace that failed to initialise

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/trace.c

    r1269 r1273  
    422422        libtrace->err.err_num = TRACE_ERR_NOERROR; 
    423423        strcpy(libtrace->err.problem,"Error message set\n"); 
     424        libtrace->format = NULL; 
     425        libtrace->uridata = NULL; 
    424426         
    425427        /* parse the URI to determine what sort of event we are dealing with */ 
     
    431433        } 
    432434         
    433         libtrace->format = NULL; 
    434435        for(tmp=formats_list;tmp;tmp=tmp->next) { 
    435436                if (strlen(scan) == strlen(tmp->name) && 
     
    441442                                } 
    442443        } 
     444        free(scan); 
     445 
    443446        if (libtrace->format == NULL) { 
    444447                trace_set_err_out(libtrace,TRACE_ERR_BAD_FORMAT, 
     
    447450        } 
    448451        libtrace->uridata = strdup(uridata); 
    449  
    450452 
    451453        /* libtrace->format now contains the type of uri 
     
    470472 
    471473 
    472         free(scan); 
    473474        libtrace->started=false; 
    474475        return libtrace; 
     
    628629        if (libtrace->format) 
    629630                libtrace->format->fin_output(libtrace); 
    630         free(libtrace->uridata); 
     631        if (libtrace->uridata) 
     632                free(libtrace->uridata); 
    631633        free(libtrace); 
    632634}