Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Leak  at pvmgs_func.c:322

Categories: ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 529.29319
Similar Warnings: 529.29320
Procedure: gs_hash_name
Trace: view
Modified: Thu Nov 26 11:37:16 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/pvmgs/pvmgs_func.c
   Enter gs_hash_name
 255 gs_hash_name(name, hash_list, ngroups, create) 
 256 char *name;
 257 GROUP_LIST_PTR hash_list;
 258 int *ngroups;
 259 int create;
 260 {
 261         char *key;
 262  
 263         int hash_index;
 264         int len = 0;
 265         int match;  
 266         int relation;
 267         int sum = 0;  
 268  
 269         GROUP_LIST_PTR current;
 270         GROUP_LIST_PTR listentry;
 271         GROUP_LIST_PTR prev;
 272  
 273         GROUP_STRUCT_PTR group;
 274  
 275         if (name == (char *) NULL || *name == '\0')    /* Uninitialized Variable (ID: 22190.29359) */
 276                 return( (GROUP_LIST_PTR) NULL);  /* Null group name error      */ 
 277  
 278         /* The following is the hash algorithm.                            */ 
 279         key = name;  
 280         while (*key != '\0')  /* sum all the characters in the string      */    /* Uninitialized Variable (ID: 22189.29358) */
 281         {    
 282                 sum += INTERVAL(MINCHAR, *key, MAXCHAR);
 283                 key++;
 284                 len++;
 285         }
 286  
 287         hash_index = sum/len;
 288         hash_index = hash_index - MINCHAR;
 289    
 290         /* hash into the table and then do a linear search for the name    */ 
 291         /* if there is a collision                                         */ 
 292         /* names are kept in lexicographic order                           */ 
 293  
 294         prev = hash_list + hash_index;
 295         current = prev->next;
 296         listentry = (GROUP_LIST_PTR) NULL;
 297  
 298         while (current != (GROUP_LIST_PTR) NULL )
 299         {
 300                 relation = strncmp(name, current->group->name,  
 301                                 MAX(current->group->len,len));    
 302  
 303                 if ( relation == 0 )  /* strings are exactly equal             */ 
 304                 {
 305                         listentry = current;
 306                         break; /* found the group name                             */ 
 307                 }
 308  
 309                 if (relation < 0)  
 310                         break; /* group name does not exist                        */ 
 311  
 312                 prev = current;             /* go to next entry in linked list */ 
 313  
 314                 current = current->next;
 315         }
 316  
 317         if (create != CREATE || listentry != (GROUP_LIST_PTR) NULL)  
 318                 return listentry;  /*return what we found, if anything         */ 
 319  
 320         /* we didn't find the group, but have been asked to create it      */ 
 321  
allocated inside call322         if ( (group = gs_struct_init(name)) == (GROUP_STRUCT_PTR) NULL)     /* Leak */
     Enter gs_hash_name / gs_struct_init
 125   gs_struct_init(groupname) 
 126   char *groupname;
 127   {
 128    
 129           GROUP_STRUCT_PTR rvalue;
 130    
referenced by returned value131           if ( (rvalue = (GROUP_STRUCT_PTR)PVM_ALLOC(sizeof(GROUP_STRUCT), GSNAME)) 
referenced by rvalue132                           ==  (GROUP_STRUCT_PTR) NULL)  
 133                   return (rvalue);    /* Out of resources                         */ 
 134    
 135           if ( (rvalue->name = 
 136                                   (char *) PVM_ALLOC(sizeof(char)*(strlen(groupname)+1), GSNAME))   /* Uninitialized Variable (ID: 531.29324) */
 137                                   == (char *) NULL)
 138           {
 139                   PVM_FREE(rvalue);
 140    
 141                   fprintf(stderr, "gs_struct_init(), couldn't allocate memory\n");
 142    
 143                   return (GROUP_STRUCT_PTR) NULL;
 144           }
 145    
 146           rvalue->len = strlen(groupname);
 147           strcpy(rvalue->name,groupname);  
 148           rvalue->ntids = 0;
 149           rvalue->tids = (int *) NULL;  
 150           rvalue->maxntids = 0;
 151           rvalue->barrier_count = -1;
 152           rvalue->barrier_reached = 0;
 153           rvalue->barrier_index = 0;
 154           rvalue->btids = (int *) NULL;
 155           rvalue->maxbtids = 0;
 156           rvalue->staticgroup = DYNAMIC;
 157           rvalue->sgroup_count = -1;
 158           rvalue->sgroup_reached = 0;
 159           rvalue->stids = (int *) NULL;
 160           rvalue->maxstids = 0;
 161           rvalue->ninfotids = 0;
 162           rvalue->infotids = (int *) NULL;  
 163           rvalue->maxinfotids = 0;
 164           rvalue->nhosts = 0;
 165           rvalue->np_onhost = (int *) NULL;
 166           rvalue->pcoord = (int *) NULL;
 167           rvalue->maxhosts = 0;
 168    
 169           return rvalue;
referenced by returned value170   }       
     Exit gs_hash_name / gs_struct_init
 323                 return (GROUP_LIST_PTR) NULL;
 324  
referenced by group325         listentry = gs_list_insert(group, prev, current);
 326  
 327         if (listentry != (GROUP_LIST_PTR) NULL)
 328                 (*ngroups)++;
 329  
 330         return(listentry);
 331 } 
Preconditions
hash_list >= 2956
create = 1
name[1] = 0
hash_list[95].next = 0
*name >= 127
strlen(name) = 1
Postconditions
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
errno' != 0




Change Warning 529.29319 : Leak

Because they are very similar, this warning shares annotations with warning 529.29320.

Priority:
State:
Finding:
Owner:
Note: