diff --git a/image/gif.c b/image/gif.c
index c2f0ae4..31c0c62 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -142,6 +142,8 @@ static void nsgif_animate(void *p)
 	int delay;
 	int f;
 
+	if(gif->gif == NULL) return;
+
 	/* Advance by a frame, updating the loop count accordingly */
 	gif->current_frame++;
 	if (gif->current_frame == (int)gif->gif->frame_count_partial) {
@@ -360,6 +362,7 @@ static void nsgif_destroy(struct content *c)
 	guit->browser->schedule(-1, nsgif_animate, c);
 	gif_finalise(gif->gif);
 	free(gif->gif);
+	gif->gif = NULL;
 }
 
 
