This is ravi rajeev working with TCS. I have problem with wild pointers. In the following code i am not able to find out the wild pointer .If some one will give me some idea how to find wild pointer and how to eliminate it,i will be greatful to you.
Following is the part of code (i.e. function) in which there is wild pointer as per my reviewer comments,
handleGetLHName(union SIGNAL *sigrec_p) /* This function is called when CELLO_PIU3_GET_LH_NAME_CFM signal is received */
union SIGNAL *huntSig_p;
huntSig_p = alloc(sizeof(OsaXpHuntFanSupervisionServer),
huntSig_p->OsaXpHuntFanSupervisionServer_r.xpInstanceId = xp_p->xpInstanceId;
huntSig_p->OsaXpHuntFanSupervisionServer_r.piuId = piuId;
/* Change the state of the fan supervision server. */
if(xp_p->fanSupervisionServer1.piuId == piuId)
xp_p->fanSupervisionServer1.state = FAN_SUPERVISION_SERVER_HUNTING;
TRACE(7, STR("fanSupervisionServer1 state: %d",
else if(xp_p->fanSupervisionServer2.piuId == piuId)
xp_p->fanSupervisionServer2.state = FAN_SUPERVISION_SERVER_HUNTING;
TRACE(7, STR("fanSupervisionServer2 state: %d",
"Unknown piuId for fan supervision server.",
"piuId: ", piuId));
/* Create the hunt path. */
hunt(huntPath_p, (OSUSER)0, 0, &huntSig_p);
/* The linkhandler string needs to be deallocated according
to the User's Guide for PRI. */
FREE_BUF((union SIGNAL **)&lnhName_p);
The code that you have posted is a part of major code tree, so its difficult to say what exactly it is, just by looking at a small piece of code. The declarations are not std. you would have header files for the abstraction that you are having . I would suggest that you trace the pgm and try to fig. your self.
I'll assume that alloc has some way to let you know it failed to allocate memory, like returning NULL. You never bother checking that.
> char *lnhName_p;
This is where you start
> strcpy(huntPath_p, lnhName_p);
This is what you do next.
Copying an uninitialised pointer - tell me you know that's a "bad thing"