Fix null terminated check