Fix typo resulting in global leak of 'tmp_length' variable