Skip to content
Tcl Source Code View Ticket
Login

View Ticket

not always compile with writeable string

Closed / Fixed218702ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:04:18
OriginalBugID: 1793 RFE
Version: 8.1b3
SubmitDate: '1999-04-13'
LastModified: '1999-05-03'
Severity: LOW
Status: Released
Submitter: pat
ChangedBy: stanton
OS: Solaris
OSVersion: 5.5.1
Machine: Other
FixedDate: '1999-05-03'
FixedInVersion: 8.1.1
ClosedDate: '2000-10-25'


Name:

Peter Weigand



Comments:

This patch may not work for all not writeable strings.



DesiredBehavior:

If you have a Tcl_Eval(interp, "do_my_command"); it does a segmentation

    error if you haven't compiled it with writeable strings.

    I have a small patch which will work for such one commands Tcl_Eval's

    and you do not need to make strings writeable.



Patch:

*** tclParse.cFri Apr  2 02:13:25 1999

--- tclParse.c.newTue Apr 13 14:01:01 1999

***************

*** 277,283 ****

--- 277,285 ----

       */

  

      savedChar = string[numBytes];

+     if (savedChar != 0) {/* not writeable? */

      string[numBytes] = 0;

+     }

  

      /*

       * Parse any leading space and comments before the first word of the

***************

*** 473,483 ****

--- 475,489 ----

  

  

      parsePtr->commandSize = src - parsePtr->commandStart;

+     if (savedChar != 0) {/* not writeable? */

      string[numBytes] = (char) savedChar;

+     }

      return TCL_OK;

  

      error:

+     if (savedChar != 0) {/* not writeable? */

      string[numBytes] = (char) savedChar;

+     }

      if (parsePtr->tokenPtr != parsePtr->staticTokens) {

  ckfree((char *) parsePtr->tokenPtr);

  parsePtr->tokenPtr = parsePtr->staticTokens;



PatchFiles:

tclParse.c





This patch just avoids the problem in the case where you are passing exactly one word to eval.  

This is really a documentation bug.  The Tcl_Eval manual entry needs to be clear that all strings passed to it must be writable.
04/15/1999 10:19 - stanton -

The patch avoids modifying strings that are already null terminated.  This should be safe since the action is a noop in any case.  Applied the patch.
05/03/1999 16:47 - stanton -
welch Closed ticket [218702ffff]. [History diff]2000-10-26 08:27:12
dgp Ticket [218702ffff]: 3 changes [History diff]2001-04-04 14:02:51
Log in (anonymous is fine) to add a comment.