Adding NULL pointer checks to list.c