On Sun, 2022-01-09 at 11:06 +0100, Henrik Carlqvist wrote: > On Sat, 08 Jan 2022 17:29:33 -0500 Paul Smith <psm...@gnu.org> wrote: > > It turns out to be innocuous because none of the callers care that > > the value of the input string is modified if we return a different > > string, but it's still wrong and should be fixed. > > If so, the easy and more correct fix might be to to remove const from > the function variable declarations rather than to restore the value.
It's not that easy. Removing the const from the argument means that we have to change all the caller's types to remove const, and that means all the callers of those methods have to remove const, etc. In any event, the bug still exists whether you say the argument is const or not: the expectation when this function is called is that after it returns the string passed to it has the same content as before it was called.