.
D 2021-12-28T23:11:04.274
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment <tt>ResultAdd()</tt>\s(generic/tclIOGT.c)\sis\ssometimes\scalled\swith\s<tt>size_t\stoWrite\s=\s0</tt>\sand\sa\s<tt>ResultBuffer\s*r</tt>\ssuch\sthat\s<tt>r->buf\s=\sNULL</tt>.\sIn\sthis\scase,\s<tt>r->used\s=\s0</tt>\sand\s<tt>r->allocated\s=\s0</tt>,\sso\s<tt>ResultAdd()</tt>\swill\snot\sallocate\sa\snew\sbuffer.\sThis\sleads\sto\s<tt>NULL\s+\s0</tt>\spointer\sarithmetic\swhen\sdoing\s<tt>r->buf\s+\sr->used</tt>,\sand\scalling\s<tt>memcpy()</tt>\swith\s<tt>NULL</tt>\sas\sthe\sdestination\s(even\sthough\sthe\scopy\slength\s<tt>toWrite</tt>\sis\s0),\sboth\sof\swhich\sare\sundefined\sbehavior.\s[https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks|UBSan\s<tt>-fsanitize=nonnull-attribute</tt>\s(GCC)\sand\s<tt>-fsanitize=pointer-overflow</tt>]\serrors\sduring\stest\siogt-1.1:\r\n\r\n<pre>\r\n<span\sstyle="font-weight:bold">tcl/generic/tclIOGT.c:1445:5:\s<span\sstyle="color:red">runtime\serror:</span>\snull\spointer\spassed\sas\sargument\s1,\swhich\sis\sdeclared\sto\snever\sbe\snull\r\ntcl/generic/tclIOGT.c:1445:12:\s<span\sstyle="color:red">runtime\serror:</span>\sapplying\szero\soffset\sto\snull\spointer</span>\r\n</pre>
J foundin 8.6.12
J is_private 0
J login chrstphrchvz
J priority 5\sMedium
J resolution None
J severity Minor
J status Open
J submitter chrstphrchvz
J subsystem 52.\sPortability\sSupport
J title Undefined\sbehavior\sin\sResultAdd()
J type Bug
K bca10e3790f6c2962c0302d6f62ef9c6fadf5752
U chrstphrchvz
Z 6121aea324b5c8db0717447dfbd0188f