why does this function give me a Segmentation fault
void fib(int **heap_loc, int n) {
    *heap_loc = malloc(sizeof(int) * n);
    for (int i = 2; i <= n; n++) {
        if (i == 0) {
            *heap_loc[i] = 0;
        } else if (i == 1) {
            *heap_loc[i] = 1;
        } else {
            *heap_loc[i] = *heap_loc[i - 1] + *heap_loc[i - 2];
        }
    }
}