diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | field.c | 4 |
2 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,9 @@ +2019-12-18 Paul Eggert <eggert@Penguin.CS.UCLA.EDU> + + Fix memcpy issue found by -fsanitize=undefined + * field.c (set_record): Don't memcpy (databuf, NULL, 0), + as the C standard says the resulting behavior is undefined. + 2019-12-16 Arnold D. Robbins <arnold@skeeve.com> * awkgram.y, command.y: Upgrade to Bison 3.5. @@ -288,7 +288,9 @@ set_record(const char *buf, int cnt, const awk_fieldwidth_info_t *fw) memset(databuf, '\0', databuf_size); } /* copy the data */ - memcpy(databuf, buf, cnt); + if (cnt != 0) { + memcpy(databuf, buf, cnt); + } /* * Add terminating '\0' so that C library routines |