You should check this result for NULL, check the EOF condition or error, and not just ignore it. In addition, without checking the result, you make a line in the line, which may have uninitialized data, because fgets failed. Indeed, you should have after fgets:
if (!result)
{
free(infoPtr);
return NULL;
}
, fgets , , - . , , NULL. , , calloc malloc , , NULL, .