Browse code

Fix error return

git-svn: trunk@2203

Nigel Horne authored on 2006/08/21 04:42:02
Showing 1 changed files
... ...
@@ -22,6 +22,9 @@
22 22
  *
23 23
  * Change History:
24 24
  * $Log: untar.c,v $
25
+ * Revision 1.31  2006/08/20 19:42:02  njh
26
+ * Fix error return
27
+ *
25 28
  * Revision 1.30  2006/07/26 09:39:08  njh
26 29
  * Fix compilation error on Windows with MSVC
27 30
  *
... ...
@@ -113,7 +116,7 @@
113 113
  * First draft
114 114
  *
115 115
  */
116
-static	char	const	rcsid[] = "$Id: untar.c,v 1.30 2006/07/26 09:39:08 njh Exp $";
116
+static	char	const	rcsid[] = "$Id: untar.c,v 1.31 2006/08/20 19:42:02 njh Exp $";
117 117
 
118 118
 #include <stdio.h>
119 119
 #include <errno.h>
... ...
@@ -257,7 +260,8 @@ cli_untar(const char *dir, int desc, unsigned int posix)
257 257
 			size = octal(osize);
258 258
 			if(size < 0) {
259 259
 				cli_errmsg("Invalid size in tar header\n");
260
-				fclose(outfile);
260
+				if(outfile)
261
+					fclose(outfile);
261 262
 				return CL_EFORMAT;
262 263
 			}
263 264
 			cli_dbgmsg("cli_untar: size = %d\n", size);
... ...
@@ -319,7 +323,8 @@ cli_untar(const char *dir, int desc, unsigned int posix)
319 319
 			if(nwritten != nbytes) {
320 320
 				cli_errmsg("cli_untar: only wrote %d bytes to file %s (out of disc space?)\n",
321 321
 					nwritten, fullname);
322
-				fclose(outfile);
322
+				if(outfile)
323
+					fclose(outfile);
323 324
 				return CL_EIO;
324 325
 			}
325 326
 			size -= nbytes;