Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Leak  at trcfile.c:3172

Categories: ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 464.29225
Procedure: trc_process_trace_event
Trace: view
Modified: Thu Nov 26 11:36:20 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/pvm3/tracer/trcfile.c
   Enter trc_process_trace_event
 3073 trc_process_trace_event( ID, name, entry_exit, index ) 
 3074 TRC_ID ID;
 3075 char *name;
 3076 int entry_exit;
 3077 int index;
 3078 {
 3079         TRC_DATADESC DD;
 3080  
 3081         TRC_TEVDESC TD;
 3082  
 3083         TRC_TEVREC TR;
   ...
 3094         short   read_short;
 3095         long    read_long;
 3096         int             read_int;
 3097  
 3098         char c;
 3099  
 3100         int i, j;
 3101         int flag;
 3102         int num;
 3103  
 3104         if ( !(ID->handle_event) )
 3105         {
 3106                 trc_find_event_end( ID );
 3107  
 3108                 return( TRC_TRUE );
 3109         }
 3110  
 3111         TD = (TRC_TEVDESC) trc_lookup_trie( TRC_EVENT_TRIE, name );
 3112  
 3113         while ( TD != NULL &&
 3114                 ( TD->entry_exit != entry_exit || TD->index != index ) )
 3115         {
 3116                 TD = TD->next;
 3117         }
 3118  
 3119         if ( TD == NULL )
 3120         {
 3121                 printf( "Error: Event \"%s\" Descriptor Not Found\n", name );
 3122  
 3123                 trc_find_event_end( ID );
 3124  
 3125                 return( TRC_FALSE );
 3126         }
 3127  
 3128         if ( !trc_find_event_str( ID, "{" ) )
 3129                 return( TRC_FALSE );
 3130          
 3131         /* matching } */ 
 3132  
 3133         DD = TD->ddesc;
 3134  
 3135         TR = (TRC_TEVREC) NULL;
 3136  
 3137         while ( DD != NULL )
 3138         {
 3139                 if ( TR == NULL )
 3140                         trptr = TR = trc_create_tevrec();   /* Leak (ID: 465.29226) */
 3141                  
 3142                 else 
 3143                         trptr = trptr->next = trc_create_tevrec();
 3144  
 3145                 trptr->ddesc = DD;
 3146  
 3147                 if ( DD->array == TEV_DATA_ARRAY )
 3148                 {
 3149                         if ( !trc_find_event_str( ID, "[" ) )
 3150                                 return( TRC_FALSE );
 3151  
 3152                         flag = fscanf( ID->trace_in, "%d", &num );
 3153  
 3154                         if ( flag != 1 )
 3155                         {
 3156                                 printf( "Error Parsing Event Record\n" );
 3157  
   ...
 3159  
 3160                                 return( TRC_FALSE );
 3161                         }
 3162  
 3163                         if ( !trc_find_event_str( ID, "{" ) )
 3164                                 return( TRC_FALSE );
 3165  
 3166                         /* matching } */ 
 3167                 }
 3168  
 3169                 else 
 3170                         num = 1;
 3171  
allocated inside call3172                 trptr->value = trc_make_value( DD->dt, ( num > 0 ) ? num : 1 );     /* Leak */
     /kat0/fletcher/SATE/2010/pvm3/tracer/trcutil.c
     Enter trc_process_trace_event / trc_make_value
 1574   trc_make_value( dt, num ) 
 1575   int dt;
 1576   int num;
 1577   {
 1578           TRC_VALUE tmp;
 1579    
 1580           int i;
 1581    
 1582           if ( num < 1 )
 1583                   return( (TRC_VALUE) NULL );
 1584    
 1585           tmp = (TRC_VALUE) NULL;
 1586    
 1587           switch ( dt ) 
 1588           {
 1589                   case TEV_DATA_NULL: break;
 1590    
 1591                   case TEV_DATA_BYTE: 
 1592                   {
 1593                           tmp = (TRC_VALUE) malloc( (unsigned) num * sizeof( char ) );
 1594                           trc_memcheck( tmp, "Character Data Pointer" );
 1595    
 1596                           break;
 1597                   }
     ...
 1627    
 1628                   case TEV_DATA_INT: 
 1629                   case TEV_DATA_UINT: 
 1630                   {
 1631                           tmp = (TRC_VALUE) malloc( (unsigned) num * sizeof( int ) );   /* Integer Overflow of Allocation Size (ID: 426.29175) */
 1632                           trc_memcheck( tmp, "Integer Data Pointer" );
 1633    
 1634                           break;
 1635                   }
 1636    
 1637                   case TEV_DATA_LONG: 
 1638                   case TEV_DATA_ULONG: 
 1639                   {
referenced by returned value1640                           tmp = (TRC_VALUE) malloc( (unsigned) num * sizeof( long ) );   /* Integer Overflow of Allocation Size (ID: 424.29178) */
referenced by tmp1641                           trc_memcheck( tmp, "Long Integer Data Pointer" );
 1642    
 1643                           break;
 1644                   }
 1645    
 1646                   case TEV_DATA_SHORT: 
 1647                   case TEV_DATA_USHORT: 
 1648                   {
 1649                           tmp = (TRC_VALUE) malloc( (unsigned) num 
 1650                                   * sizeof( short ) );   /* Integer Overflow of Allocation Size (ID: 428.29176) */
 1651                           trc_memcheck( tmp, "Short Integer Data Pointer" );
 1652    
 1653                           break;
     ...
 1659                   {
 1660                           printf( "Value Data Type %d Not Implemented\n", dt );
 1661    
 1662                           break;
 1663                   }
 1664    
 1665                   default: 
 1666                           printf( "Warning: Unknown Value Data Type %d\n", dt );
 1667           }
 1668    
 1669           return( tmp );
referenced by returned value1670   } 
     Exit trc_process_trace_event / trc_make_value
 3173  
referenced by trptr->value3174                 if ( trptr->value == NULL )
 3175                 {
 3176                         printf( "Error Allocating Value dt=%d num=%d\n",
 3177                                 DD->dt, num );
 3178  
 3179                         return( TRC_FALSE );
 3180                 }
 3181  
 3182                 trptr->num = num;
 3183  
 3184                 switch ( DD->dt ) 
 3185                 {
 3186                         case TEV_DATA_NULL: break;
 3187  
 3188                         case TEV_DATA_BYTE: 
 3189                         {
 3190                                 if ( DD->array == TEV_DATA_ARRAY )
 3191                                 {
 3192                                         if ( !trc_find_event_str( ID, "\"" ) )
 3193                                                 return( TRC_FALSE );
 3194  
   ...
 3334                                         if ( i < num - 1 )
 3335                                         {
 3336                                                 if ( !trc_find_event_str( ID, "," ) )
 3337                                                         return( TRC_FALSE );
 3338                                         }
 3339                                 }
 3340  
 3341                                 break;
 3342                         }
 3343  
 3344                         case TEV_DATA_LONG: 
 3345                         {
 3346                                 for ( i=0 ; i < num ; i++ )
 3347                                 {
 3348                                         flag = fscanf( ID->trace_in, "%ld", &read_long );
 3349  
 3350                                         if ( flag != 1 )
 3351                                         {
 3352                                                 printf( "Error Parsing Event Record\n" );
 3353  
 3354                                                 trc_find_event_end( ID );
 3355  
 3356                                                 return( TRC_FALSE );
 3357                                         }
 3358  
 3359                                         TRC_ARR_VALUE_OF( trptr->value, long, i ) = 
 3360                                                 read_long;
 3361  
 3362                                         if ( i < num - 1 )
 3363                                         {
 3364                                                 if ( !trc_find_event_str( ID, "," ) )
 3365                                                         return( TRC_FALSE );
 3366                                         }
   ...
 3534                 }
 3535  
 3536                 DD = DD->next;
 3537         }
 3538  
 3539         (ID->handle_event)( ID, TD, TR );
 3540  
 3541         trc_free_tevrec( &TR );
 3542  
 3543         return( TRC_TRUE );
 3544 } 
Preconditions
ID->handle_event != 0
((char*)&((char*)*TRC_EVENT_TRIE[36].value)[24])[4] = 8
((char*)&((char*)*TRC_EVENT_TRIE[36].value)[24])[8] != 128
((char*)TRC_EVENT_TRIE[36].value)[8] = entry_exit
((char*)TRC_EVENT_TRIE[36].value)[12] = index
TRC_EVENT_TRIE[36].valid != 0
*TRC_EVENT_TRIE[36].str = *name
strlen(TRC_EVENT_TRIE[36].str) = strlen(name)
TRC_EVENT_TRIE >= 3520




Change Warning 464.29225 : Leak

Priority:
State:
Finding:
Owner:
Note: