fix a couple of out-of-bounds reads and writes
This addresses #1676, and a second bug that was revealed by fixing the first one. I'll merge on 2020-08-15 if there are no objections.
This addresses #1676, and a second bug that was revealed by fixing the first one. I'll merge on 2020-08-15 if there are no objections.