https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110147
Mark Wielaard <mark at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-06-08
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #3 from Mark Wielaard <mark at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> --- a/libiberty/rust-demangle.c
> +++ b/libiberty/rust-demangle.c
> @@ -1569,8 +1569,11 @@ str_buf_append (struct str_buf *buf, const char
> *data, size_t len)
> if (buf->errored)
> return;
>
> - memcpy (buf->ptr + buf->len, data, len);
> - buf->len += len;
> + if (len)
> + {
> + memcpy (buf->ptr + buf->len, data, len);
> + buf->len += len;
> + }
> }
>
> static void
That is probably the correct fix/workaround. str_buf_append is the
function/callback used to build up the demangled string. If it gets an empty
NULL/0 string it really shouldn't do anything (so you could also do a if (len
== 0) return at the top).
We might want to ping [email protected] (who wrote the original v0 rust demangler)
in case he thinks this might also need to raise an error flag. But that would
technically be a separate bug I think.