libgimpconfig: unfix loop condition and fix if condition

The loop was right, but the following if was meant to check if
the token was terminated correctly so it needs to be *p.