diff options
author | Alexander Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2019-09-10 07:54:53 +0100 |
---|---|---|
committer | Arnold Robbins <arnold@skeeve.com> | 2019-09-10 09:54:53 +0300 |
commit | ad9bd2f40a89ec9533b92254b86a756cf4f40fd4 (patch) | |
tree | 01f502156effeb559a0a6ec3217bcc4c87ef1746 /lex.c | |
parent | cbf924342b63a095a4c6842280c3085b1b63ae45 (diff) | |
download | one-true-awk-ad9bd2f40a89ec9533b92254b86a756cf4f40fd4.tar.gz |
Avoid creating an out-of-bounds pointer in word() (#48)
As it is never dereferenced in the n == -1 case it shouldn't cause any
problems. However, UBSAN complains about this, so it is required to run
the tests when compiling with -fsanitize=undefined.
Diffstat (limited to 'lex.c')
-rw-r--r-- | lex.c | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -461,9 +461,8 @@ int word(char *w) int c, n; n = binsearch(w, keywords, sizeof(keywords)/sizeof(keywords[0])); -/* BUG: this ought to be inside the if; in theory could fault (daniel barrett) */ - kp = keywords + n; if (n != -1) { /* found in table */ + kp = keywords + n; yylval.i = kp->sub; switch (kp->type) { /* special handling */ case BLTIN: |