fix possible segfault on incorrect sp/SP flag usage