Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

char passed to isalpha, must be int #22

Open
ashesman opened this issue Feb 2, 2020 · 0 comments
Open

char passed to isalpha, must be int #22

ashesman opened this issue Feb 2, 2020 · 0 comments
Assignees
Labels

Comments

@ashesman
Copy link

ashesman commented Feb 2, 2020

Line 44 of decode.c

if (!(isalnum(src[j]) || '+' == src[j] || '/' == src[j])) { break; }

Should be

if (!(isalnum(**(int)**src[j]) || '+' == src[j] || '/' == src[j])) { break; }

Otherwise an error: array subscript has type 'char' [-Werror=char-subscripts] occurs. Referring to GCC 9s ctype.h:

/* These macros are intentionally written in a manner that will trigger
a gcc -Wall warning if the user mistakenly passes a 'char' instead
of an int containing an 'unsigned char'. Note that the sizeof will
always be 1, which is what we want for mapping EOF to __CTYPE_PTR[0];
the use of a raw index inside the sizeof triggers the gcc warning if
__c was of type char, and sizeof masks side effects of the extra __c.
Meanwhile, the real index to __CTYPE_PTR+1 must be cast to int,
since isalpha(0x100000001LL) must equal isalpha(1), rather than being
an out-of-bounds reference on a 64-bit machine. */

@jwerle jwerle self-assigned this Apr 13, 2020
@jwerle jwerle added the bug label Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants