Fixed handling of invalid array access in mem2reg code