fix `get-output-{bytes,string}' with bad starting index, no ending index

Closes PR 13933