Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at lpvmgen.c:4293

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2760.2815
Procedure: pvm_addmhf
Trace: View
Modified: Wed Sep 2 12:45:22 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/lpvmgen.c
   Enter pvm_addmhf
 4176 pvm_addmhf(src, tag, ctx, f) 
 4177         int src, tag, ctx;                      /* message source, context, tag */ 
 4178 #ifdef  IMA_SCO 
 4179         int (*f)(int);                          /* handler function */ 
 4180 #else 
 4181         int (*f)();                             /* handler function */ 
 4182 #endif 
 4183 {
 4184         int i;          /* temp local */ 
 4185         int hand;       /* index into handles[] array -->> internal use only */ 
 4186                                 /* - not for user */ 
 4187         int mhid;       /* message handler index -->> into dhandles[] */ 
 4188                                 /* -->> give to user */ 
 4189         int exists = 0;
 4190         TEV_DECLS 
 4191  
 4192         if (TEV_EXCLUSIVE) {
 4193                 if (TEV_DO_TRACE(TEV_ADDMHF,TEV_EVENT_ENTRY)) {
 4194                         TEV_PACK_INT( TEV_DID_RST, TEV_DATA_SCALAR, &src, 1, 1 );
 4195                         TEV_PACK_INT( TEV_DID_RMC, TEV_DATA_SCALAR, &tag, 1, 1 );
 4196                         TEV_PACK_INT( TEV_DID_RCX, TEV_DATA_SCALAR, &ctx, 1, 1 );
 4197                         TEV_FIN;
 4198                 }
 4199         }
 4200  
 4201         /*
 4202         *  confirm that does not already exist within "handles"
 4203         *  this includes "wild-card" options in both directions too...
 4204         *
 4205         *  search from most recently added message handler to system 
 4206         *  added message handlers 
 4207         */ 
 4208         for ( i=nhandles-1 ; i >= 0 && !exists ; i-- ){
 4209                 if ((handles[i].header.tag == -1 
 4210                                 || handles[i].header.tag == tag || tag == -1)
 4211                 && (handles[i].header.ctx == -1 
 4212                                 || handles[i].header.ctx == ctx || ctx == -1)
 4213                 && (handles[i].header.src == -1 
 4214                                 || handles[i].header.src == src || src == -1))
 4215                 {
 4216                         exists++;
 4217                 }
 4218         }
 4219  
 4220         /*
 4221         *  see if there are any already on free list 
 4222         *  -  use existing if on free list 
 4223         *  -  create new if none free - two scenarios:
 4224         *       1. may be initial message handlers 
 4225         *       2. may be additional message handlers and lists just full 
 4226         *
 4227         *  note: ndhandles never decreases - thus if less than nhandles,
 4228         *  must be some free slots...
 4229         */ 
 4230         if ( exists )
 4231                         mhid = PvmExists;
 4232         else if (ndhandles > nhandles){
 4233                 /*
 4234                 *  there exist some free slots 
 4235                 */ 
 4236                 mhid = fl_dhandles;             /* take from head of free list */ 
 4237                 nhandles++;                             /* incr actual # of active headers */ 
 4238  
 4239                 /*
 4240                 *  move next one to head of free list 
 4241                 *  if tail of list - will move "tail marker" (-1) to 
 4242                 *  fl_dhandles to indicte empty list 
   ...
 4252                 /* dhandles[mhid].handle        no change here as should be next */ 
 4253                 /* contiguous on handles[] */ 
 4254  
 4255                 hand = dhandles[mhid].handle;   /* set to index -> handles[] */ 
 4256                 handles[hand].mhid = mhid;              /* set to corresponding mhid */ 
 4257                 handles[hand].header.tag = tag;
 4258                 handles[hand].header.ctx = ctx;
 4259                 handles[hand].header.src = src;
 4260                 handles[hand].f = f;    /* sonnofabeech! */ 
 4261         }
 4262         else{
 4263                 /* no free slots available - will have to allocate more slots...
 4264                 *  two scenarios for this:
 4265                 *    1. first time adding message handlers - none ever 
 4266                 *           allocated.
 4267                 *    2. all presently allocated are filled and active - but 
 4268                 *           been here before.
 4269                 *
 4270                 *  note: since no free slots, must have case of:
 4271                 *           ndhandles == nhandles 
 4272                 *
 4273                 *  ndhandles : is the "high-water" mark as it is never decreased 
 4274                 *  nhandles  : indicates the actual number of active handles 
 4275                 */ 
 4276                 if (ndhandles == 0){
 4277                         /* first time here - allocate new memory... */ 
 4278                         dhandles = TALLOC(++ndhandles, struct dhandler, "dhandles");
 4279                         handles = TALLOC(++nhandles, struct mhandler, "mhandle");
 4280                 }
 4281                 else{
 4282                         /* been here! - reallocate more space... */ 
true4283                         dhandles = TREALLOC(dhandles, ++ndhandles, struct dhandler);
 4284                         handles = TREALLOC(handles, ++nhandles, struct mhandler);
 4285                 }
 4286  
 4287                 mhid = ndhandles - 1;           /* set index into dhandles */ 
 4288  
 4289                 /*
 4290                 *  fill the lists now...
 4291                 */ 
 4292  
dhandles <= 40954293                 dhandles[mhid].mhid = mhid;             /* set to self */     /* Null Pointer Dereference */  /* Buffer Underrun (ID: 2762.2817) */
Preconditions
&$unknown_1284102 != 0
dhandles != 0
ndhandles = -1
nhandles = 1
pvmmytid != -1
pvmtoplvl != 0
pvmtrc.trctid != pvmmytid
pvmtrc.trctid >= 1
Postconditions
bytes_after(handles)' = 48 * nhandles + 48
ctx' = -1
dhandles' = 0
exists' = 0
f' = $param_4
i' = nhandles - 2
mhid' = ndhandles
ndhandles' = ndhandles + 1
nhandles' = nhandles + 1
pvmampushed' = 0
pvmamtraced' = pvmtoplvl
pvmtoplvl' = 0
src' != -1




Change Warning 2760.2815 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: