Skip to content
Tcl Source Code Artifact [f067701563]
Login

Artifact [f067701563]

Artifact f0677015632062019dfe9556f12488a875a7197b0376f694e380d5e36dcca90d:

Ticket change [f067701563] - New ticket [1dab713a3808489e|1dab713a38] <i>Uninitialized-variable use while parsing &#39;*&#39; in BRE-mode regexps</i>. by tgl on 2021-01-08 18:10:46.
D 2021-01-08T18:10:46.576
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment brenext(),\swhen\sparsing\sa\s'*'\squantifier,\sforgets\sto\sreturn\sany\s"value"\r\nfor\sthe\stoken;\sper\sthe\sequivalent\scase\sin\snext(),\sit\sshould\sreturn\r\nvalue\s1\sto\sindicate\sthat\sgreedy\srather\sthan\snon-greedy\sbehavior\sis\r\nwanted.\s\sThe\sresult\sis\sthat\sthe\scompiled\sregexp\scould\sbehave\slike\s'x*?'\r\nrather\sthan\sthe\sintended\s'x*',\sif\swe\sare\sunlucky\senough\sto\shave\r\na\szero\sin\sv->nextvalue\sat\sthis\spoint.\s\sIn\sPostgres\sit\sseems\snot\stoo\shard\r\nfor\sthat\sto\shappen\swhen\sthe\sregexp\sbegins\swith,\ssay,\s'.*';\sand\sin\sany\scase\r\nvalgrind\scomplains\sabout\suninitialized-value\susage.\s\sI've\shad\sa\smuch\r\nharder\stime\sreproducing\sit\sin\sTcl,\sbut\sone\sway\sthat\sseems\sreliable\sis\r\n\r\n$\stclsh\r\n%\sregexp\s-inline\s{\\u0000}\s{}\r\n%\sregexp\s-inline\s{(?b).*}\s{abc}\r\n{}\r\n\r\nOf\scourse\sthe\scorrect\sanswer\sis\s"abc",\sand\sthat\sis\swhat\syou\sget\s(usually)\r\nif\syou\sdo\snothing,\sor\ssome\sother\sregexp,\sbefore\sthe\sbuggy\sone.\r\n\r\nThe\sfix\sis\sa\sone-liner:\r\n\r\n---\sgeneric/regc_lex.c~\s2019-08-28\s08:46:06.000000000\s-0400\r\n+++\sgeneric/regc_lex.c\s\s2021-01-08\s12:57:11.056650507\s-0500\r\n@@\s-1005,7\s+1005,7\s@@\sbrenext(\r\n\s\s\s\s\s\s\s\sif\s(LASTTYPE(EMPTY)\s||\sLASTTYPE('(')\s||\sLASTTYPE('^'))\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sRETV(PLAIN,\sc);\r\n\s\s\s\s\s\s\s\s}\r\n-\s\s\s\s\s\s\sRET('*');\r\n+\s\s\s\s\s\s\sRETV('*',\s1);\r\n\s\s\s\s\s\s\s\sbreak;\r\n\s\s\s\s\scase\sCHR('['):\r\n\s\s\s\s\s\s\s\sif\s(HAVE(6)\s&&\s\s*(v->now+0)\s==\sCHR('[')\s&&
J foundin 8.6.10
J is_private 0
J login tgl
J priority 5\sMedium
J private_contact 26864b65f1c6ce8bda86f87ed9c554e19ac0390d
J resolution None
J severity Minor
J status Open
J submitter tgl
J subsystem 43.\sRegexp
J title Uninitialized-variable\suse\swhile\sparsing\s'*'\sin\sBRE-mode\sregexps
J type Bug
K 1dab713a3808489ef0a23be683b3d2058fbd3f27
U tgl
Z 09cfc82da350f0561a55eddfbaf7ef60