Fixed possible crash on invalid request in SAPI