The function assumed that the buffer would not contain a trailing OK packet that completes a multi-result response.