Skip to content

Commit

Permalink
Merge pull request lh3#12 from iamleot/cc_func-avoid-undefined-behaviour
Browse files Browse the repository at this point in the history
Avoid undefined behaviour when using ctype(3) functions in relex() (possible fix for lh3#11)
  • Loading branch information
onetrueawk authored Mar 3, 2019
2 parents c3c7c13 + 031aac8 commit 115fac0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion b.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ THIS SOFTWARE.
#define DEBUG

#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -831,7 +832,7 @@ int relex(void) /* lexical analyzer for reparse */
* not without first adapting the entire
* program to track each string's length.
*/
for (i = 1; i < NCHARS; i++) {
for (i = 1; i <= UCHAR_MAX; i++) {
if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg expr %.10s...", lastre);
if (cc->cc_func(i)) {
Expand Down

0 comments on commit 115fac0

Please sign in to comment.