I would think you would need to add check on your externally accepted values (using assert might be a start) Like :
- checking
tm>0 ler>0C[i]<tmA[i]!=NULLB[i]!=NULL
As mentionned in the comment it an off by one issue :
in LER the values should be from 0 to tm-1
or use B[i][j]=C[k]-1; at line 88
1
solved Another coredump issue in C