public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5854] D: fix UBSAN Date: Thu, 9 Dec 2021 08:46:38 +0000 (GMT) [thread overview] Message-ID: <20211209084638.AAEEA3858C27@sourceware.org> (raw) https://gcc.gnu.org/g:5791bf7a0a7705be6c3989c445e7c739220f3290 commit r12-5854-g5791bf7a0a7705be6c3989c445e7c739220f3290 Author: Martin Liska <mliska@suse.cz> Date: Mon Dec 6 13:02:22 2021 +0100 D: fix UBSAN Fixes: gcc/d/expr.cc:2596:9: runtime error: null pointer passed as argument 2, which is declared to never be null gcc/d/ChangeLog: * expr.cc: Call memcpy only when length != 0. Diff: --- gcc/d/expr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 2831eefc4ba..8e1d43e2b8f 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -2598,7 +2598,8 @@ public: /* Copy the string contents to a null terminated string. */ dinteger_t length = (e->len * e->sz); char *string = XALLOCAVEC (char, length + 1); - memcpy (string, e->string, length); + if (length > 0) + memcpy (string, e->string, length); string[length] = '\0'; /* String value and type includes the null terminator. */
reply other threads:[~2021-12-09 8:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211209084638.AAEEA3858C27@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).