Fix a bug at buffer.set_size