Text  |   XML   |   Visible Warnings:

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

Categories: LANG.ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 2568.2600
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  
allocated inside call2560         ht_del = 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_del->ht_hosts2561         ht_save = ht_new(1);   /* Leak (ID: 2569.2601) */
 2562         ht_merge(ht_save, hosts);
 2563  
 2564         mp2 = mesg_new(0);
 2565         mp2->m_tag = DM_DELHOSTACK;   /* Null Pointer Dereference (ID: 2574.2606) */
 2566         mp2->m_wid = mp->m_wid;
 2567         mp2->m_dst = mp->m_src;
 2568  
 2569         mp3 = mesg_new(0);
 2570         mp3->m_tag = DM_HTDEL;   /* Null Pointer Dereference (ID: 2573.2605) */
 2571         pkint(mp3, hosts->ht_serial);
 2572  
 2573         pkint(mp2, count);
 2574         while (count-- > 0) {
 2575                 upkstralloc(mp, &buf);
 2576                 if (hp = nametohost(hosts, buf)) {   /* Uninitialized Variable (ID: 2572.2604) */
 2577                         if (tidtohost(ht_del, hp->hd_hostpart)) {
 2578                                 pkint(mp2, PvmDupHost);
 2579  
 2580                         } else {
 2581                                 if (hp->hd_hostpart == myhostpart)
 2582                                         pkint(mp2, PvmBadParam);
 2583  
 2584                                 else {
 2585                                         ht_insert(ht_del, hp);
     /u1/paul/SATE/2010/c/pvm/pvm3/src/host.c
     Enter dm_delhost / 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_insert
Preconditions
&$unknown_628948 >= 1
&$unknown_628951 = &$unknown_628950 + 136
&$unknown_628951 >= 4232
&$unknown_628957 >= 512
&$unknown_628958 = 0
hosts->ht_last <= 1
((char*)&$unknown_628956)[4] != myhostpart
numpmsgs = 0
Postconditions
((char*)$unknown_628950)[8]' = ((char*)&$unknown_628950)[8]
((char*)$unknown_628952)[8]' = ((char*)&$unknown_628952)[8]
((char*)$unknown_628950)[8]' = $unknown_628950
((char*)$unknown_628952)[8]' = $unknown_628952
$unknown_628951' = &freepmsgs.m_link
((char*)&$unknown_628951)[8]' = ((char*)&$unknown_628950)[8]
$unknown_628952' = &$unknown_628952
((char*)&$unknown_628952)[16]' = 0
((char*)&$unknown_628952)[24]' = 0
((char*)&$unknown_628952)[32]' = 0
((char*)&$unknown_628952)[36]' = 0
((char*)&$unknown_628952)[40]' = 1
((char*)&$unknown_628952)[42]' = 1
((char*)&$unknown_628952)[42]' = 0
((char*)&$unknown_628952)[60]' = 0
((char*)&$unknown_628952)[8]' = &$unknown_628952
$unknown_628956' = $unknown_628956 + 1
count' = &$unknown_628948 - 1
freefrags.fr_link' = &$unknown_628952
freepmsgs.m_link' = &$unknown_628950
freepmsgs.m_rlink' = &$unknown_628950 + 136
$heap_36423' = 0
bytes_after(&$heap_36423)' = 40
$heap_36423' is allocated by malloc
$heap_36423' is allocated
bytes_before(&$heap_36423)' = 0
strlen(&$heap_36423)' = 0
((char*)&$heap_36423)[32]' = &$unknown_628958
((char*)&$heap_36423)[4]' >= -1
((char*)&$heap_36423)[4]' <= 1
((char*)&$heap_36423)[8]' = ((char*)&$heap_36423)[8] + 1
$heap_36424' = 0
bytes_after(&$heap_36424)' = 16
$heap_36424' is allocated by malloc
$heap_36424' is allocated
bytes_before(&$heap_36424)' = 0
strlen(&$heap_36424)' = 0
$heap_36425' = 0
bytes_after(&$heap_36425)' = 40
$heap_36425' is allocated by malloc
$heap_36425' is allocated
bytes_before(&$heap_36425)' = 0
strlen(&$heap_36425)' = 0
((char*)&$heap_36425)[32]' = &$heap_36426
((char*)&$heap_36425)[4]' = 1
$heap_36426' = 0
bytes_after(&$heap_36426)' = 16
$heap_36426' is allocated by malloc
$heap_36426' is allocated
bytes_before(&$heap_36426)' = 0
strlen(&$heap_36426)' = 0
hh' = &$unknown_628957
hp' = &$unknown_628956
hp' = &$unknown_628956
ht_del' = &$heap_36423
ht_save' = &$heap_36425
htp' = &$heap_36423
mask' = 0
mp' = $param_2
mp2' = &$unknown_628950
mp3' = &$unknown_628950
n' = 2
numpmsgs' = 48




Change Warning 2568.2600 : Leak

Priority:
State:
Finding:
Owner:
Note: