[antlr-interest] Possible bug in C-target runtime function antlr3BitsetClone

troy runkel trunkel at gmail.com
Fri Oct 19 08:20:56 PDT 2007


I believe I found a bug in the antlr3BitsetClone function in the
antlr3bitset.c module of the C-target runtime.  The function currently
calls

    /* Allocate memory for the bitset structure itself
     */
    bitset  = antlr3BitsetNew(8 * inSet->length);

which passes the number of bytes to allocate to the antlr3BitsetNew
function.  However the antlr3BitsetNew function expects the number of
BITS to allocate, so the function call should look like

    /* Allocate memory for the bitset structure itself
     */
    bitset  = antlr3BitsetNew(ANTLR3_BITSET_BITS * inSet->length);

The antlr3BitsetNew function rounds all requests for less than 512
bits to 512, so the current code will work as long as you always need
less than 512 bits.

Troy Runkel


More information about the antlr-interest mailing list