- Fixed irregularly occuring core dump bug.
This commit is contained in:
69
SCinter.c
69
SCinter.c
@ -75,22 +75,6 @@
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pInter->argv = NULL;
|
||||
pInter->argv = (char **)malloc(MAXPAR*sizeof(char *));
|
||||
if(pInter->argv == NULL)
|
||||
{
|
||||
free(pInter);
|
||||
return NULL;
|
||||
}
|
||||
for(i = 0; i < MAXPAR; i++)
|
||||
{
|
||||
pInter->argv[i] = (char *)malloc(MAXLEN*sizeof(char));
|
||||
if(pInter->argv[i] == NULL)
|
||||
{
|
||||
free(pInter);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
pInter->iDeleting = 0;
|
||||
return pInter;
|
||||
}
|
||||
@ -210,11 +194,13 @@ extern char *SkipSpace(char *pPtr);
|
||||
{
|
||||
int iCount = 0;
|
||||
int iRet;
|
||||
int i;
|
||||
int i, argc;
|
||||
char pBueffel[1024];
|
||||
CommandList *pCommand = NULL;
|
||||
char pBrk[] = {" \r\n\0"};
|
||||
char *pPtr;
|
||||
char **argv = NULL;
|
||||
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
@ -240,36 +226,27 @@ extern char *SkipSpace(char *pPtr);
|
||||
}
|
||||
|
||||
/* convert to argc, argv */
|
||||
pPtr = SkipSpace(pText);
|
||||
if(pPtr)
|
||||
{
|
||||
pPtr = stptok(pPtr,self->argv[0],255,pBrk);
|
||||
}
|
||||
while(pPtr != NULL)
|
||||
{
|
||||
iCount++;
|
||||
pPtr = SkipSpace(pPtr);
|
||||
if(!pPtr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pPtr = stptok(pPtr,self->argv[iCount],255,pBrk);
|
||||
}
|
||||
self->argv[iCount][0] = '\0';
|
||||
|
||||
argc = 0;
|
||||
Text2Arg(pText,&argc,&argv);
|
||||
|
||||
/* the first one must be the target object. If not given an empty
|
||||
command string was given which will be silently ignored */
|
||||
if(iCount < 1)
|
||||
if(argc < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(argv[0] == NULL)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: failed to parse command",eError);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* find it */
|
||||
pCommand = FindCommand(self,self->argv[0]);
|
||||
pCommand = FindCommand(self,argv[0]);
|
||||
if(!pCommand)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: Object -> %s <- NOT found",
|
||||
self->argv[0]);
|
||||
argv[0]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return -1;
|
||||
|
||||
@ -280,8 +257,19 @@ extern char *SkipSpace(char *pPtr);
|
||||
self->eOut = eStatus;
|
||||
Tcl_ResetResult((Tcl_Interp *)self->pTcl);
|
||||
MacroPush(pCon);
|
||||
iRet = pCommand->OFunc(pCon, self, pCommand->pData, iCount, self->argv);
|
||||
iRet = pCommand->OFunc(pCon, self, pCommand->pData, argc, argv);
|
||||
MacroPop();
|
||||
|
||||
/* delete argv */
|
||||
for(i = 0; i < argc; i++)
|
||||
{
|
||||
if(argv[i] != NULL)
|
||||
{
|
||||
free(argv[i]);
|
||||
}
|
||||
}
|
||||
free(argv);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
@ -393,11 +381,6 @@ extern char *SkipSpace(char *pPtr);
|
||||
Tcl_DeleteInterp(pTcl);
|
||||
}
|
||||
|
||||
for(i = 0; i < MAXPAR; i++)
|
||||
{
|
||||
free(self->argv[i]);
|
||||
}
|
||||
free(self->argv);
|
||||
free(self);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user