D 2017-07-17T16:59:39.879 J icomment Well,\sthis\sseems\sto\shave\srepercussions\s-\stoday\sI\swould\scheck\smy\sidea\swith\snew\sflag\sTCL_OWN_OBJREF\sand\shave\sverified\sat\swhich\splaces\severywhere\sin\stcl\s(and\ssome\smodules\slike\sthread,\setc)\sit\smay\sbe\sneeded.\r\nThereby\sI\sfound\smany\splaces,\swhere\sit's\scurrently\swrong\s(e.\sg.\susage\sof\sreleased\sobject,\swrong\sfree\sor\seven\sleaks).
\r\nToo\smany\sto\slist\sall\sthis\shere...
\r\nJust\sas\san\sexample,\ssee\sTcl_ObjSetVar2(...,\smatchVarObj,\sNULL,\semptyObj,\s...)\sthat\swill\suse\salready\sreleased\sobject\semptyObj\sif\s10\slines\sabove\sthe\ssame\sobject\semptyObj\swill\sbe\sreleased\sin\strace\sby\sTcl_ObjSetVar2(...,\sindexVarObj,\sNULL,\semptyObj,\s...)\s.\r\nNote\sthat\sin\scurrent\sversions\sthis\sdoes\snot\shave\sTcl_DecrRefCount(emptyObj)\sin\serror\scases\s(since\sauto-release\sin\s[510663a99e3a096bb7bab7314eb59fc805335318]),\sbut\sit\sdoes\sno\smatter\sbecause\sthis\scan\sbe\sreleased\sin\strace\sby\sset.\r\n\r\nI\swould\slike\sto\sfix\sall\ssuch\serrors\s(and\ssimilar)\sfor\s8.5th,\s8.6th\sand\strunk\sbranches\s(together\swith\sintroducing\sof\salready\ssuggested\snew\sflag\sTCL_OWN_OBJREF\sor\susing\ssome\sother\ssolution\slike\snew\sinternal\sfunction\sTclObjOwnAndSetVar),\sbut\sfirstly\sI\swould\slike\sto\sknow\swhat\sTCT\sthinks\sabout\s(new\sflag?,\snew\sfunction?,\ssomething\sother?).\r\nIMHO\sbut\s(very-very\scontroversial)\sauto-release\smade\sin\s[510663a99e3a096bb7bab7314eb59fc805335318]\sis\snot\sreally\sa\ssolution\sand\sshould\sbe\srewritten.\r\n\r\nPlease\snote\salso,\sthat\sthis\sbehavior\sis\sundocumented,\sso\smany\speople\smake\sstill:\r\n
\r\nTcl_Obj\s*newObj\s=\sSomethingReturnsNewObjOfTypeX(...);\r\nif\s(Tcl_ObjSetVar2(...,\svarObj,\sNULL,\snewObj,\s...)\s==\sNULL)\s{\r\n\s\sTcl_DecrRefCount(newObj);\r\n\s\sreturn\sTCL_ERROR;\r\n}\r\n
\r\nWhat\sis\scurrently\swrong\s(because\ssince\s[510663a99e3a096bb7bab7314eb59fc805335318]\sit\sis\sdouble\sdecreased,\sand\scan\scause\ssegfault). J login sebres J mimetype text/x-fossil-wiki K 578155d5a19b348dc1a9fe96cc2c067a59326a89 U sebres Z 26634078d602a7d91aad84abe48eec3c