Fix char array access issue on matrix generation.