[erlang-bugs] fmtq bug by inspection
Perry Smith
pedzsan@REDACTED
Mon Jun 16 22:12:39 CEST 2008
This looks like a bug to me:
static char* fmtq(char* ptr, int* buf)
{
int c;
switch((c=*ptr++)) {
<snip>
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
c = c - '0';
if ((*ptr >= 0) && (*ptr <= 7)) { <<<<<
c = (c << 3) | (*ptr - '0');
ptr++;
if ((*ptr >= 0) && (*ptr <= 7)) { <<<<<
c = (c << 3) | (*ptr - '0');
ptr++;
}
}
break;
}
*buf = c;
return ptr;
}
Shouldn't it be:
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7':
c = c - '0';
if ((*ptr >= '0') && (*ptr <= '7')) { /* added single quotes */
c = (c << 3) | (*ptr - '0');
ptr++;
if ((*ptr >= '0') && (*ptr <= '7')) { /* added single quotes */
c = (c << 3) | (*ptr - '0');
ptr++;
}
}
I found this simply by looking at the compiler warnings.
HTH
Perry
More information about the erlang-bugs
mailing list