Fix data overflow problem

The size of max_length is 3 but the loop is 4, so writing to max_length overrides other variables (in my case, exetudemultiply), which causes problems.