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.
This commit is contained in:
parent
af93386ffc
commit
5791bf7a0a
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user