.
D 2002-01-16T22:48:26
J assignee andreas_kupries
J cmimetype text/plain
J comment \s\s\s\s*\sTcl\sVersion:\s8.3.4\n\s\s\s\s*\sOS\sPlatform\sand\sVersion:\s\sWindows\sNT\s4.0\n\s\s\s\s*\sProblem\sBehavior:\n\n"gets\sstdin"\scrashes\n\n\s\s\s\s*\sExpected\sBehavior\nShouldn't\scrash...\n\n\s\s\s\s*\sConcise\sCode\sSample\s(if\sapplicable)\n\nSorry,\sbut\sI\sdon't\shave\stime\sto\sput\stogether\sa\sconcise\ntestcase,\sbut\sI'll\sdescribe\sthe\sproblem\sas\sI\sunderstand\nit\sand\sinclude\sthe\spatch\sI\smade\sto\sfix\sit.\n\nFor\sour\sWindows\sapplication\sI've\sdefined\sa\sconsole\svery\nsimilar\sto\sthe\sbuiltin\sTk\sconsole.\s\sThis\sconsole\nsupports\sboth\sstdout\sand\sstdin.\s\sThese\sconsole\schannels\n\sexecute\sTcl\scode\s(similar\sto\sTkConsolePrint)\sto\nperform\sthe\sI/O\soperation.\n\nThe\scode\sin\sTcl_GetsObjCmd()\sobtains\sthe\sResultObj,\nthen\spasses\sthis\sObj\sto\sTcl_GetsObj().\s\sTcl_GetsObj\nthen\sextracts\sthe\sbytes\spointer\sfrom\sthe\sObj\s(line\n3104)\sand\sholds\sonto\sit\suntil\slater.\n\nThen\sthe\schannel\sInput\sProc\sis\scalled\sand\sreturns\sthe\nrequested\sdata.\s(Uh\sOh!)\n\nNext,\ssome\sarithmetic\sis\sdone\sbetween\sthe\sObj->bytes\npointer\sand\sthe\ssaved\spointer\s(from\sbefore\sthe\scall\sto\nthe\sInput\sProc)\sand\sat\sthis\spoint\sbad\sthings\shappen!\n\nThe\sproblem\sis\sthat\sthis\sObj\sis\snot\sreference\scounted\nand\sis\sreally\sowned\sby\sthe\sinterp.\s\sDown\sinside\sthe\nchannel\sInput\sProc\swhile\sexecuting\ssome\sTcl\scode,\sthe\ninterp\sdecides\sto\sfree\sthe\sObj\sand\sreplace\sit!\s\sThe\nGets\scode\shas\sno\sway\sto\sknow\sthis.\n\nTo\sfix\sthis\sproblem\sI\schange\sTcl_GetsObjCmd\sto\salways\ncreate\sa\sNewObj,\sforget\susing\sthe\sinterps\sObj.\s\sThis\nseems\ssafer\sto\sme\ssince\syou\sreally\shave\sno\sclue\swhat's\ngoing\sto\shappen\sinside\sthe\sChannel\scode.\n\nHere's\sthe\schanges\sto\sTcIOCmd.c\score-8-3-4\s(revision:\n1.7.2.1):\n\ncvs\sdiff\s-p\stclIOCmd.c\nIndex:\stclIOCmd.c\n===================================================================\nRCS\sfile:\s/cvsroot/tcl/tcl/generic/tclIOCmd.c,v\nretrieving\srevision\s1.7.2.1\ndiff\s-p\s-r1.7.2.1\stclIOCmd.c\n***\stclIOCmd.c\s\s2001/08/06\s22:24:11\s\s\s\s\s1.7.2.1\n---\stclIOCmd.c\s\s2002/01/16\s22:05:57\n***************\sTcl_GetsObjCmd(dummy,\sinterp,\sobjc,\sobjv\n***\s228,243\s****\n\s\s\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\s\s\s\s\s\s}\n\s\s\n!\s\s\s\s\sif\s(objc\s==\s3)\s{\n!\s\s\s\s\s\s\s/*\n!\s\s\s\s\s\s\s\s*\sVariable\sgets\sline,\sinterp\sget\sbytecount.\n!\s\s\s\s\s\s\s\s*/\n!\s\n!\s\s\s\s\s\s\slinePtr\s=\sTcl_NewObj();\n!\s\s\s\s\s}\n!\s\s\s\s\selse\s{\n!\s\s\s\s\s\s\slinePtr\s=\sTcl_GetObjResult(interp);\n!\s\s\s\s\s}\n\s\s\n\s\s\s\s\s\slineLen\s=\sTcl_GetsObj(chan,\slinePtr);\n\s\s\s\s\s\sif\s(lineLen\s<\s0)\s{\n---\s228,234\s----\n\s\s\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\s\s\s\s\s\s}\n\s\s\n!\s\s\s\s\slinePtr\s=\sTcl_NewObj();\n\s\s\n\s\s\s\s\s\slineLen\s=\sTcl_GetsObj(chan,\slinePtr);\n\s\s\s\s\s\sif\s(lineLen\s<\s0)\s{\n***************\sTcl_GetsObjCmd(dummy,\sinterp,\sobjc,\sobjv\n***\s261,266\s****\n---\s252,259\s----\n\s\s\s\s\s\s\s\sresultPtr\s=\sTcl_GetObjResult(interp);\n\s\s\s\s\s\s\s\sTcl_SetIntObj(resultPtr,\slineLen);\n\s\s\s\s\s\s\s\s\s\sreturn\sTCL_OK;\n+\s\s\s\s\s}\selse\s{\n+\s\s\s\s\s\s\sTcl_SetObjResult(interp,\slinePtr);\n\s\s\s\s\s\s}\n\s\s\s\s\s\sreturn\sTCL_OK;\n\s\s}\n
J foundin obsolete:\s8.3.4
J priority 5\sMedium
J resolution None
J status Open
J submitter bgriffin
J subsystem 24.\sChannel\sCommands
J title Problem\sin\sgets\sw/custom\schannels
J type Bug
K 504642ffffffffffffffffffffffffffffffffff
U bgriffin
Z 36d9a20cfa83d889ab903ef0a444daa0