git: csh(1): Silence -Wuse-after-free warnings from GCC 12.5

Aaron LI aly at crater.dragonflybsd.org
Sat Oct 17 06:08:29 PDT 2026


commit dea249a60d184c0d31415cfbc0be0e084652249d
Author: Aaron LI <aly at aaronly.me>
Date:   Sat Oct 17 21:04:55 2026 +0800

    csh(1): Silence -Wuse-after-free warnings from GCC 12.5
    
    GCC 12.5 generates the following -Wuse-after-free warnings, which are
    all false positives, so silence them for this vendor source.  I'd like
    to submit the code fixes to upstream and then do a vendor update.
    
    ```
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.func.c: In function 'iconv_catgets':
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.func.c:2600:34: warning: pointer may be used after 'realloc' [-Wuse-after-free]
     2600 |                 dest = p + (dest - buf);
          |                            ~~~~~~^~~~~~
    In file included from /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.func.c:32:
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.h:499:25: note: call to 'realloc' here
      499 | # define xrealloc(p, i) realloc(p, i)
          |                         ^~~~~~~~~~~~~
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.func.c:2597:26: note: in expansion of macro 'xrealloc'
     2597 |                 if ((p = xrealloc(buf, buf_size * 2)) == NULL)
          |                          ^~~~~~~~
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.proc.c: In function 'morecommand':
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.proc.c:731:17: warning: pointer used after 'realloc' [-Wuse-after-free]
      731 |     d = ncmdstr - cmdstr;
          |                 ^
    In file included from /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.proc.c:32:
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.h:499:25: note: call to 'realloc' here
      499 | # define xrealloc(p, i) realloc(p, i)
          |                         ^~~~~~~~~~~~~
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.proc.c:730:15: note: in expansion of macro 'xrealloc'
      730 |     ncmdstr = xrealloc(cmdstr, cmdmax * sizeof(*cmdstr));
          |               ^~~~~~~~
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/tw.init.c: In function 'tw_str_add':
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/tw.init.c:125:55: warning: pointer 'ptr' may be used after 'realloc' [-Wuse-after-free]
      125 |                 sl->list[i] = sl->buff + (sl->list[i] - ptr);
          |                                                       ^
    In file included from /usr/src/bin/csh/csh/../../../contrib/tcsh-6/tw.init.c:32:
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/sh.h:499:25: note: call to 'realloc' here
      499 | # define xrealloc(p, i) realloc(p, i)
          |                         ^~~~~~~~~~~~~
    /usr/src/bin/csh/csh/../../../contrib/tcsh-6/tw.init.c:121:20: note: in expansion of macro 'xrealloc'
      121 |         sl->buff = xrealloc(sl->buff, sl->tbuff * sizeof(Char));
          |                    ^~~~~~~~
    ```

Summary of changes:
 bin/csh/csh/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/dea249a60d184c0d31415cfbc0be0e084652249d


-- 
DragonFly BSD source repository


More information about the Commits mailing list