shithub: trueawk

Download patch

ref: 115fac05872c0def5dbc9959a3c7a4d078c454c5
parent: c3c7c1370e9a9969bdcaf2018c5e62096ac15c55
parent: 031aac816ddcb215bb65d6edfbfa61ee5bbf5bf3
author: onetrueawk <bwkster@gmail.com>
date: Sun Mar 3 10:08:25 EST 2019

Merge pull request #12 from iamleot/cc_func-avoid-undefined-behaviour

Avoid undefined behaviour when using ctype(3) functions in relex() (possible fix for #11)

--- a/b.c
+++ b/b.c
@@ -27,6 +27,7 @@
 #define	DEBUG
 
 #include <ctype.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -831,7 +832,7 @@
 					 * 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)) {
--