Fixed segmentation fault error in string length check