Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Leak  at ddpro.c:2561

Categories: LANG.ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 2569.2601
Procedure: dm_delhost
Trace: View
Modified: Wed Sep 2 12:41:29 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
   /u1/paul/SATE/2010/c/pvm/pvm3/src/ddpro.c
   Enter dm_delhost
 2529 dm_delhost(hp, mp) 
 2530         struct hostd *hp;
 2531         struct pmsg *mp;
 2532 {
 2533         int count;
 2534         char *buf;
 2535         struct pmsg *mp2;               /* DELHOSTACK message */ 
 2536         struct pmsg *mp3;               /* HTDEL message */ 
 2537         struct htab *ht_del;    /* hosts to delete */ 
 2538         struct htab *ht_save;   /* remaining hosts */ 
 2539         int hh;
 2540  
 2541 /* XXX danger, this doesn't check if already doing a host add/delete */ 
 2542  
 2543         /* sanity check count */ 
 2544  
 2545         if (upkint(mp, &count)) {
 2546                 pvmlogerror("dm_delhost() bad msg format\n");
 2547                 return 0;
 2548         }
 2549         if (count < 1 || count > (tidhmask >> (ffs(tidhmask) - 1))) {
 2550                 pvmlogerror("dm_delhost() bad count\n");
 2551                 return 0;
 2552         }
 2553  
 2554         /*
 2555         * read host names from message, generate delete and save sets 
 2556         * and a DELHOSTACK reply message with result code for each host.
 2557         * set SHUTDOWN flag for each host in delete set.
 2558         */ 
 2559  
 2560         ht_del = ht_new(1);   /* Leak (ID: 2568.2600) */
allocated inside call2561         ht_save = ht_new(1);     /* Leak */
     /u1/paul/SATE/2010/c/pvm/pvm3/src/host.c
     Enter dm_delhost / ht_new
 483   struct htab * 
 484   ht_new(siz) 
 485           int siz;                /* initial length of ht_hosts[] */ 
 486   {
 487           struct htab *htp;
 488    
 489           if (siz < 1)
 490                   siz = 1;
 491           htp = TALLOC(1, struct htab, "ht1");
 492           BZERO((char*)htp, sizeof(struct htab));   /* Null Pointer Dereference (ID: 2469.2497) */
 493           htp->ht_last = siz;
referenced by returned value494           htp->ht_hosts = TALLOC(siz + 1, struct hostd*, "ht2");
referenced by htp->ht_hosts495           BZERO((char*)htp->ht_hosts, (siz + 1) * sizeof(struct hostd*));   /* Null Pointer Dereference (ID: 2468.2496) */
 496           return htp;
referenced by ht_new$return->ht_hosts497   } 
     Exit dm_delhost / ht_new
referenced by ht_save->ht_hosts2562         ht_merge(ht_save, hosts);
     /u1/paul/SATE/2010/c/pvm/pvm3/src/host.c
     Enter dm_delhost / ht_merge
referenced by dst->ht_hosts664   ht_merge(dst, src) 
 665           struct htab *dst, *src;
 666   {
 667           int hh;
 668           struct hostd *hp;
 669    
 670           for (hh = src->ht_last; hh > 0; hh--)
 671                   if (hp = src->ht_hosts[hh])
 672                           ht_insert(dst, hp);
       Enter dm_delhost / ht_merge / ht_insert
referenced by htp->ht_hosts507     ht_insert(htp, hp) 
 508             struct htab *htp;
 509             struct hostd *hp;
 510     {
 511             int hh;
 512             int i;
 513             unsigned long mask = 0, tmpmask;
 514      
 515             int *dsigs;
 516             int ndsigs;
 517             int found;
 518             int d;
 519      
 520             hh = (hp->hd_hostpart & tidhmask) >> (ffs(tidhmask) - 1);
 521      
 522             /* extend ht_hosts[] if no room */ 
 523      
 524             if (hh > htp->ht_last) {
 525                     int n = htp->ht_last;
 526      
 527                     htp->ht_last = (hh * 3) / 2;
 528                     htp->ht_hosts = TREALLOC(htp->ht_hosts, htp->ht_last + 1, struct hostd*);
referenced by $param_1529                     while (++n <= htp->ht_last)
 530                             htp->ht_hosts[n] = 0;   /* Null Pointer Dereference (ID: 2570.2602) */  /* 6 more... */
 531             }
 532      
 533             /* if already have an entry, take this as an update XXX kind of a hack */ 
 534      
 535             if (htp->ht_hosts[hh]) {        /* already have an entry */ 
 536      
 537                     struct hostd *hp2 = htp->ht_hosts[hh];
 538      
 539                     if (hp->hd_name) {
 540                             if (hp2->hd_name)
 541                                     PVM_FREE(hp2->hd_name);
 542                             hp2->hd_name = STRALLOC(hp->hd_name);   /* Null Pointer Dereference (ID: 2474.2502) */
 543                     }
 544                     if (hp->hd_arch) {
 545                             if (hp2->hd_arch)
 546                                     PVM_FREE(hp2->hd_arch);
 547                             hp2->hd_arch = STRALLOC(hp->hd_arch);   /* Null Pointer Dereference (ID: 2473.2501) */
 548                     }
 549                     hp2->hd_dsig = hp->hd_dsig;
 550                     hp2->hd_mtu = hp->hd_mtu;
 551                     hp2->hd_sad = hp->hd_sad;
 552                     hp2->hd_speed = hp->hd_speed;
 553      
 554             } else {                                        /* add new entry */ 
 555      
 556                     htp->ht_hosts[hh] = hp;
 557                     if (hh)
 558                             htp->ht_cnt++;
 559                     hp->hd_ref++;
 560             }
 561      
 562             /* update number of arches */ 
 563      
leaked564             dsigs = TALLOC( htp->ht_cnt, int, "dsigs");
       Exit dm_delhost / ht_merge / ht_insert
     Exit dm_delhost / ht_merge
Preconditions
&$unknown_629043 >= 1
&$unknown_629046 >= 512
hosts->ht_last >= 1
Postconditions
$unknown_629045' = $unknown_629045 + 1
count' = &$unknown_629043
dst' = &$heap_36491
$heap_36489' = 0
bytes_after(&$heap_36489)' = 40
$heap_36489' is allocated by malloc
$heap_36489' is allocated
bytes_before(&$heap_36489)' = 0
strlen(&$heap_36489)' = 0
((char*)&$heap_36489)[32]' = &$heap_36490
((char*)&$heap_36489)[4]' = 1
$heap_36490' = 0
bytes_after(&$heap_36490)' = 16
$heap_36490' is allocated by malloc
$heap_36490' is allocated
bytes_before(&$heap_36490)' = 0
strlen(&$heap_36490)' = 0
$heap_36491' = 0
bytes_after(&$heap_36491)' = 40
$heap_36491' is allocated by malloc
$heap_36491' is allocated
bytes_before(&$heap_36491)' = 0
strlen(&$heap_36491)' = 0
((char*)&$heap_36491)[32]' = 0
((char*)&$heap_36491)[4]' >= -1
((char*)&$heap_36491)[4]' <= 1
((char*)&$heap_36491)[8]' = ((char*)&$heap_36491)[8] + 1
$heap_36492' = 0
bytes_after(&$heap_36492)' = 16
$heap_36492' is allocated by malloc
$heap_36492' is allocated
bytes_before(&$heap_36492)' = 0
strlen(&$heap_36492)' = 0
hh' = &$unknown_629046
hh' = hosts->ht_last
hp' = &$unknown_629045
hp' = &$unknown_629045
hp' = $param_1
ht_del' = &$heap_36489
ht_save' = &$heap_36491
htp' = &$heap_36491
mask' = 0
mp' = $param_2
n' = 2
src' = hosts




Change Warning 2569.2601 : Leak

Priority:
State:
Finding:
Owner:
Note: