don't dereference NULL upon fdopen failure

There were several unchecked use of fdopen(); replace them with xfdopen()
that checks and dies.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/upload-pack.c b/upload-pack.c
index b3471e4..38ddac2 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -108,7 +108,7 @@
 	int i;
 	struct rev_info revs;
 
-	pack_pipe = fdopen(fd, "w");
+	pack_pipe = xfdopen(fd, "w");
 	init_revisions(&revs, NULL);
 	revs.tag_objects = 1;
 	revs.tree_objects = 1;
@@ -255,7 +255,7 @@
 
 	/* pass on revisions we (don't) want */
 	if (!shallow_nr) {
-		FILE *pipe_fd = fdopen(pack_objects.in, "w");
+		FILE *pipe_fd = xfdopen(pack_objects.in, "w");
 		if (!create_full_pack) {
 			int i;
 			for (i = 0; i < want_obj.nr; i++)