Fix invalid memory access introduced in 6f832724ef942f133f6f8d0a06d7377beea8f7a6