diff options
| author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-02-24 10:32:37 (GMT) | 
|---|---|---|
| committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-02-24 10:32:37 (GMT) | 
| commit | 99a24e7883c680bb555d044a04e458a57be677a1 (patch) | |
| tree | 14f05a69e135a61b7dae6dbf980cf4d692618b86 | |
| parent | 76adf3151bfbab01fe206c3bf2f2d0f8091da188 (diff) | |
| download | tcl-99a24e7883c680bb555d044a04e458a57be677a1.zip tcl-99a24e7883c680bb555d044a04e458a57be677a1.tar.gz tcl-99a24e7883c680bb555d044a04e458a57be677a1.tar.bz2 | |
Raise error on invalid flags
| -rw-r--r-- | generic/tclEncoding.c | 24 | 
1 files changed, 23 insertions, 1 deletions
| diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index d969779..00ca5e8 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -1275,7 +1275,18 @@ Tcl_ExternalToUtfDStringEx(      Tcl_Size dstLen;      const char *srcStart = src; -    Tcl_DStringInit(dstPtr); /* Must always be initialized before returning */ +    /* DO FIRST - Must always be initialized before returning */ +    Tcl_DStringInit(dstPtr); + +    if (flags & (TCL_ENCODING_START|TCL_ENCODING_END)) { +	/* TODO - what other flags are illegal? - See TIP 656 */ + 	Tcl_SetResult(interp, +	    "Parameter error: TCL_ENCODING_{START,STOP} bits set in flags.", +	    TCL_STATIC); +	Tcl_SetErrorCode(interp, "TCL", "ENCODING", "ILLEGALFLAGS", NULL); +	return TCL_ERROR; +    } +      dst = Tcl_DStringValue(dstPtr);      dstLen = dstPtr->spaceAvl - 1; @@ -1559,7 +1570,18 @@ Tcl_UtfToExternalDStringEx(      const char *srcStart = src;      Tcl_Size dstLen; +    /* DO FIRST - must always be initialized on return */      Tcl_DStringInit(dstPtr); + +    if (flags & (TCL_ENCODING_START|TCL_ENCODING_END)) { +	/* TODO - what other flags are illegal? - See TIP 656 */ + 	Tcl_SetResult(interp, +	    "Parameter error: TCL_ENCODING_{START,STOP} bits set in flags.", +	    TCL_STATIC); +	Tcl_SetErrorCode(interp, "TCL", "ENCODING", "ILLEGALFLAGS", NULL); +	return TCL_ERROR; +    } +      dst = Tcl_DStringValue(dstPtr);      dstLen = dstPtr->spaceAvl - 1; | 
