Fix C++ assertion "!m_rows || idx < (size_t)m_rows" failed