Check for null matrix when getting rows and cols