diff options
author | Bruno Haible <bruno@clisp.org> | 2022-02-08 01:16:48 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-02-08 01:16:48 +0100 |
commit | d89cab871231a82c0783ce520d692f08a32f2da6 (patch) | |
tree | cfbebfe047aee488b5f0fe98f8b2c0652c27e505 | |
parent | 6d53a2dbe0ad692d0f36fd394b7e1962d9a81730 (diff) | |
download | gperf-d89cab871231a82c0783ce520d692f08a32f2da6.tar.gz |
tests: Fix undefined behaviour.
* tests/test2.c (main): Cast bytes to unsigned before shifting left.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | tests/test2.c | 2 |
2 files changed, 6 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2022-02-07 Bruno Haible <bruno@clisp.org> + + tests: Fix undefined behaviour. + * tests/test2.c (main): Cast bytes to unsigned before shifting left. + 2022-01-05 Bruno Haible <bruno@clisp.org> Release gperf-3.2. diff --git a/tests/test2.c b/tests/test2.c index c1c08cc..ecd3d18 100644 --- a/tests/test2.c +++ b/tests/test2.c @@ -45,7 +45,7 @@ main (int argc, char *argv[]) char *p = buf; while (fread (p, 2, 1, stdin) == 1) { - if ((p[0] << 8) + p[1] == '\n') + if (((unsigned char) p[0] << 8) + (unsigned char) p[1] == '\n') break; p += 2; } |