Possible Bug?

In the game The Labrynth

On the input char ,I have a char **COL
After reading the inputs, I then have a test case
// Reading in

        for (i = 0; i < R; i++) {
       // C of the characters in '#.TC?' (i.e. one line of the ASCII maze).
        scanf("%s", COL[i]); fgetc(stdin);
    }

//Test Case (Also note DEBUG(…) = fprintf(stderr, …))

        for (int r = 0; r < R; r++)
    {
        DEBUG("\n");
        for (int c = 0; c < C; c++)
        {
            DEBUG("%c", COL[r][c]);
        }
    }

It works as expected, and prints out all the characters
However once I enter initNodeMap function, things get weird. I should also point out, we enter the initNodeMap immediately after coming out of the test case.

void initNodeMap(Vector *v, Node **map, char **COL, int C, int R) {
int r, c;
DEBUG("init_nodemap and last char is %c, R = %i, C = %i\n", COL[R-1][C-1], R, C);
for (r = 0; r < R; r++)
{
    DEBUG("\n");
    for (c = 0; c < C; c++)
    {
        Node *p = calloc(1, sizeof(Node));
        p->r = r;
        p->c = c;
        //p->data = (char) COL[r][c]; // commented out
        if (r == R -1) // Notice at the beginning we accessed and printed out COL[R-1][C-1]
            if (c == C -1)
            {/***This is where it trips a Segmentation fault  when accessing COL[r][c]*/
                DEBUG("\nr = %i, c = %i", r,c);
                DEBUG("r = %i c = %i and last char = %c",r,c, COL[r][c]);  

So unless I am mistaken, there seems to be something wrong. COL[R-1][C-1] is accessible and does not seg fault, but then seemingly for no reason, it does.

Is this a bug or am I missing something?

Allocation for char **COL

    char **COL = calloc(R+1,sizeof(char*));
for (int i = 0; i < R; i++)
    COL[i] = calloc(C+1, sizeof(char*));

Paste bin of code in entirety…
NOPE

typedef struct Moon * Finger;
Moon * myFinger = malloc(sizeof Finger);

Sorry, I’m not sure what you mean by that

Shouldn’t that be:
COL[i] = calloc(C+1, sizeof(char));
?
Probably not an issue since sizeof (char *) > sizeof(char).

In doubt, put stars in your Christmas tree, not your code.

If you don’t like fortune cookies, which is probably the worse way to get advices by the way, simply try to switch the position of the two following pieces of code:

char **COL = calloc(R+1,sizeof(char*));
for (int i = 0; i < R; i++)
    COL[i] = calloc(C+1, sizeof(char*));

Node **map = calloc(R, sizeof(Node*));
for (int i = 0; i < R; i++)
    map[i] = calloc(C, sizeof(Node*));

The memory error will jump to another place, nearer to the bug origin, “demonstrating” that walking your COL is safe, whereas your map leads to big holes leading themselves to the memory below (the one the OS has decorated with pointy sticks).

Steve, yes you are right