Fix crazy broken code exposed by warning fix.

Previously idx was an unsigned type, meaning when it was assigned -1 it actually got a crazy huge number.  I don't know how THAT didn't crash, but now it's a nice int and it shouldn't bother anyone anymore.
Fixes #8552