None of the answers I have found seem to address my issue. I am creating a dynamic 3d array in C and later freeing it. I can store and later access the data stored in this array using a nested for loop but I get an access violation when trying to free it using the same nested for loop setup. Where am I going wrong? 

```
unsigned char ***buff1;
int r, c;
someFunction(&buff1, &r, &c);
for(int i = 0; i < r; ++i)
{
  for(int j = 0; j < c; ++j)
  {
    free(buff1[i][j]);
  }
  free(buff1[i]);
}
free(buff1);

someFunction(unsigned char**** buff, int *nR, int *nC)
{
  ...
  *buff = (SQLCHAR***)malloc(*nR * sizeof(SQLCHAR**));
  for(int i = 0; i < *nR; ++i)
  {
    (*buff)[i] = (SQLCHAR**)malloc(*nC * sizeof(SQLCHAR**));
    for(int j = 0; j < *nC; ++j)
    {
      (*buff)[i][j] = (SQLCHAR*)malloc(256);
    }
  }
}

```