diff options
author | Norihiro Tanaka <noritnk@kcn.ne.jp> | 2014-11-15 22:21:34 -0800 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2014-11-16 07:45:35 -0800 |
commit | a07a473b558709741ef9a39a97a65ddcedc41eb3 (patch) | |
tree | 20d5a69cd9f97d9d57f7007350503676c019875a | |
parent | 37d90d5ae4c4a42f59fa655529483827f687d91c (diff) | |
download | grep-a07a473b558709741ef9a39a97a65ddcedc41eb3.tar.gz |
dfa: avoid undefined behavior
* src/dfa.c (dfassbuild): Don't call memcpy with a second
argument of NULL, even when the size (3rd argument) is 0.
-rw-r--r-- | src/dfa.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -3660,8 +3660,11 @@ dfassbuild (struct dfa *d) sup->musts = NULL; sup->charclasses = xnmalloc (sup->calloc, sizeof *sup->charclasses); - memcpy (sup->charclasses, d->charclasses, - d->cindex * sizeof *sup->charclasses); + if (d->cindex) + { + memcpy (sup->charclasses, d->charclasses, + d->cindex * sizeof *sup->charclasses); + } sup->tokens = xnmalloc (d->tindex, 2 * sizeof *sup->tokens); sup->talloc = d->tindex * 2; |