Add checks to doc == NULL, as pointed by Michael, Daniel.
1 file changed