From: Ben Pfaff Date: Mon, 25 Jan 2021 00:30:42 +0000 (-0800) Subject: str: Avoid passing null pointer to memcpy() in ds_put_substring(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b7074fa6baa35e1e04e7943d8b1b7f6c43a49c5;p=pspp str: Avoid passing null pointer to memcpy() in ds_put_substring(). --- diff --git a/src/libpspp/str.c b/src/libpspp/str.c index a58473192e..e06f626571 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -1481,7 +1481,8 @@ ds_put_cstr (struct string *st, const char *s) void ds_put_substring (struct string *st, struct substring ss) { - memcpy (ds_put_uninit (st, ss_length (ss)), ss_data (ss), ss_length (ss)); + if (ss.length) + memcpy (ds_put_uninit (st, ss_length (ss)), ss_data (ss), ss_length (ss)); } /* Returns ds_end(ST) and THEN increases the length by INCR. */