The error is: heap-buffer-overflow. I'm running a block of code that multiplies matrices. Address sanitizer is throwing me an error at a specific line while trying to multiply two matrices. On my IDE, no errors or warnings show up, however, address sanitizer is throwing an error here and I'm not too sure why. The matrix has entries scanned in from the user, below is a snippet of the code not working. The snippet address sanitizer is throwing an error on is bolded. Thanks.
snippet:
double **productMatrixT;
productMatrixT = (double **)malloc(rowT*sizeof(double));
for(i = 0; i < rowT; i++)
{
productMatrixT[i] = malloc(column*sizeof(double));
}
double sum = 0;
for(i = 0; i < column; i++)
{
for(j = 0; j < row; j++)
{
for(k = 0; k < rowT; k++)
{
**sum = sum + matrixT[i][k] * matrix[k][j];** <---- /*says this line is a cause for a problem*/
}
productMatrixT[i][j] = sum;
sum = 0;
}
}
}
free:
for(i = 0; i < rowT; i++)
{
free(productMatrixT[i]);
}
free(productMatrixT);