[En-Nut-Discussion] BUGFIX: NutDecodeBase64()

Damian Slee damian at commtech.com.au
Fri Sep 19 07:02:09 CEST 2003


hehe, this has caught me out a couple of times as well porting some code from VC to GCC.

What was happening was the if statment was never failing when 'code == -1'

    for (tp = sp = str; *sp; ++sp) {
        if ((code = PRG_RDB(&base64dtab[(int) *sp])) == -1)
            continue;

This is because base64dtab[] is an array of char, and -1 is 255.

'code' is an int.  -1 is 65535.

255 != 65535.

Changing 'code' & 'last' to char, from int, fixes the problem.



More information about the En-Nut-Discussion mailing list