Fix crash in processQuery when res is null