Skip to content
Tcl Source Code Artifact [8acabbadb8]
Login

Artifact [8acabbadb8]

Artifact 8acabbadb8957321f31f9c3263487add22ffd0693ae3abf2ec8ed3e4b76708f3:

Ticket change [8acabbadb8] - Ticket [bd94500678e837d7|bd94500678] <i>SEGFAULT by conversion of unicode (out of BMP) to byte-array.</i> status still Pending with 3 other changes by sebres on 2019-02-06 10:08:37.
D 2019-02-06T10:08:37.841
J icomment <i>>\swhy\swould\sextensions\smodify\s'ch'\sin-between?</i>\r\n\r\nWell,\sI\sfound\salready\s2\spieces\swithin\scycles\son\smy\sside,\sthat\sdoing\sthis:\sthe\sone\sby\scompare\sof\s2\suni-strings\s(both\shave\sset\sch\sto\szero\sexactly\sas\sin\sfixed\scase),\sand\sanother\sby\sfast\scompression\sof\sstring\s(ch\s=\suni-char\sfrom\sa\sdictionary,\sif\sit\sis\swithin\sand\sshorter\sin\sbits).\r\n\r\nThe\spoint\sis\s-\sin\sconstructs\slike\sfollowing,\syou\scould\snever\sbe\ssure\sthat\s"ch"\shas\sbeen\snever\schanged:\r\n<code><pre>\r\n\s\s\s\swhile\s(\ssrc\s<\ssrcEnd\s)\s{\r\n\t//\s...here...\s(like\s`Tcl_UniChar\sch\s=\s0;\s/*\sto\ssilence\sstupid\scompiler\swarning\s*/`)\r\n\tsrc\s+=\sTclUtfToUniChar(src,\s&ch);\r\n\t//\s...or\seven\shere...\s(like\s`ch\s=\sSomeTransform(ch);\s*dst1++\s=\sch;\s*dst2++\s=\sch;`)\r\n\t//\s...or\seven\scalc...\s(like\s`ch\s=\sOperationAsPartOfCheckSum(ch);\s...;\ssum\s+=\sch;`)\r\n\s\s\s\s}\r\n</pre></code>\r\nJust\sbecause\spreviously\sthe\sreturn\svalue\swas\salways\s>=\s1\s(and\salso\sdocumented\sthis\sway\s"The\sreturn\svalue\sis\sthe\snumber\sof\sbytes\sread\sfrom\ssrc.").\s\r\nAnd\sit\sis\svery\svery\slong\stime\sso.\r\n\r\nAnd\ssimply\sthink\sabout\swhat\sthis\scould\scause\sthen\s(endless\scycles,\sbuffer\soverrun,\setc).<br/>\r\nWould\snot\swe\spay\stoo\shigh\spenalty\sto\sretain\sstubs/EIAS/compatibility\sfor\srare\scase\s"char\sis\sout\sof\sBMP"\s(and\sglyphs\sare\smostly\sunneeded\sby\s99%\sof\sapp's).\r\n\r\n<i>>\sI'm\sopen\sfor\ssuggesions\sfor\simprovement</i>\r\n\r\nAnd\sI\shave\ssome\sof\sthese:\r\n<ul>\r\n<li>either\sa\snew\sfunction\slike\s<code>Tcl_UtfToUniCharEx/TclUtfToUniCharEx</code>\sthat\sdoing\sthe\snew\simplementation\s(and\slet\sboth\sprevious\s<code>Tcl_UtfToUniChar/TclUtfToUniChar</code>\suntouched).\r\nStill\sbetter\sthis\snew\sfunction\scould\sget\snew\sparam\s<code>len</code>,\sthat\sI\salways\smissed\s(one\sshould\spreviously\sbe\ssure\sthat\s<code>src</code>\sis\sNTS\sor\slong\senough\sto\savoid\saccess\sviolation).\r\n</li>\r\n<li>or\san\sintended\schange\sof\sStubs,\sso\ssome\snew\sparameter\slike\s<code>Tcl_UtfToUniChar(srcPtr,\sch,\sbmpOnly)</code>\sthat\scontrols\snew\simplementation\sas\swell\sas\sforses\sthe\sdeveloper\schange\s(and\sverify)\shis\scode.</li>\r\n</ul>\r\n\r\nBoth\sways\sretain\sthe\sstability\s(avoids\svulni/SF/BO)\sand\sgive\sdevelopers\sa\schance\sfor\scorrect\sprocessing\sout\sof\sBMP\schars\s(if\sit\sis\sneeded\sat\sall)\susing\sthis\snew\sfunction\s(stub).\r\n\r\nAnyway\sare\syou\sagree\sthat\sa\stheoretical\sincompatibility\sis\smany\smany\stimes\sbetter\sas\sBO/segfault\s(or\seven\spotential\svulnerability)?
J login sebres
J mimetype text/x-fossil-wiki
K bd94500678e837d7ed50cf6d5000df8f38cd5e39
U sebres
Z ace20e8db61df592b7d8242dad7a02fa