X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=hswitch.c;h=15ddbc61bb29fc17a7441efa0b9a59110b97c065;hb=3201adca0560cf447024e23b0e572c9b5137111c;hp=7c7f5c3f4e4a6e6d5f61710c5aaeea8518c1dea2;hpb=d8234df96ab8fb03ed71f6358f7211ebe725b495;p=tclrobot.git diff --git a/hswitch.c b/hswitch.c index 7c7f5c3..15ddbc6 100644 --- a/hswitch.c +++ b/hswitch.c @@ -1,5 +1,5 @@ /* - * $Id: hswitch.c,v 1.3 2000/12/07 20:16:11 adam Exp $ + * $Id: hswitch.c,v 1.5 2001/11/08 10:23:02 adam Exp $ */ #include #include @@ -17,7 +17,7 @@ static int skipSpace (const char *cp) { int i = 0; - while (strchr (SPACECHR, cp[i])) + while (cp[i] && strchr (SPACECHR, cp[i])) i++; return i; } @@ -172,7 +172,6 @@ static int tagEnd (Tcl_Interp *interp, struct tagInfo *tag, memcpy (value, tag->body_start, body_end - tag->body_start); value[body_end - tag->body_start] = '\0'; Tcl_SetVar (interp, "body", value, 0); - free (value); while (tp) { char vname[TAG_MAX_LEN+30]; @@ -186,6 +185,7 @@ static int tagEnd (Tcl_Interp *interp, struct tagInfo *tag, free (tp0); } tcl_err = Tcl_Eval (interp, tag->code); + free (value); if (tcl_err == TCL_ERROR) { printf ("Error: code=%d %s\n", tcl_err, interp->result);