Dennis:

You shot yourself in the foot.

    int *comb;
...
    comb = ( int * ) calloc( (size_t) k, sizeof(int) );
    for ( i = 0; i < k; ++i)
        *( comb + i * sizeof(int) ) = i;

'comb' is a pointer to an int.
As such, 'comb + n' is really '(caddr_t)comb + n * sizeof (int))'
This line:
        *( comb + i * sizeof(int) ) = i;
writes outside the range of the allocated space,
causing heap corruption, which leads to the core dump.

The line should read:
        *( comb + i ) = i;
or:
        comb[i] = i;

You were just lucky that it worked at all
with the first set of parameters.

Roger

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to