fixed a bug that in some situation an error is caused by reading from a 0-length slice