summaryrefslogtreecommitdiff
path: root/gzlib.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:32:36 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:32:36 -0700
commit67cc20d0041a32bee12bd9eb20ae218f91b73f77 (patch)
treed7e1b94bd15c30efd57cf9036f5fe89306b6bba0 /gzlib.c
parent7751bd4c715ea8478113e34b49b5a794a4642e8e (diff)
downloadzlib-1.2.4-pre1.tar.gz
zlib-1.2.4-pre1.tar.bz2
zlib-1.2.4-pre1.zip
zlib 1.2.4-pre1v1.2.4-pre1
Diffstat (limited to 'gzlib.c')
-rw-r--r--gzlib.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gzlib.c b/gzlib.c
index 03240b1..6fdb08a 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -147,6 +147,14 @@ local gzFile gz_open(path, fd, mode)
147 return NULL; 147 return NULL;
148 } 148 }
149 149
150 /* save the path name for error messages */
151 state->path = malloc(strlen(path) + 1);
152 if (state->path == NULL) {
153 free(state);
154 return NULL;
155 }
156 strcpy(state->path, path);
157
150 /* open the file with the appropriate mode (or just use fd) */ 158 /* open the file with the appropriate mode (or just use fd) */
151 state->fd = fd != -1 ? fd : 159 state->fd = fd != -1 ? fd :
152 open(path, 160 open(path,
@@ -170,14 +178,6 @@ local gzFile gz_open(path, fd, mode)
170 if (state->mode == GZ_APPEND) 178 if (state->mode == GZ_APPEND)
171 state->mode = GZ_WRITE; /* simplify later checks */ 179 state->mode = GZ_WRITE; /* simplify later checks */
172 180
173 /* save the path name for error messages */
174 state->path = malloc(strlen(path) + 1);
175 if (state->path == NULL) {
176 free(state);
177 return NULL;
178 }
179 strcpy(state->path, path);
180
181 /* save the current position for rewinding (only if reading) */ 181 /* save the current position for rewinding (only if reading) */
182 if (state->mode == GZ_READ) { 182 if (state->mode == GZ_READ) {
183 state->start = LSEEK(state->fd, 0, SEEK_CUR); 183 state->start = LSEEK(state->fd, 0, SEEK_CUR);
@@ -450,7 +450,8 @@ const char * ZEXPORT gzerror(file, errnum)
450 return NULL; 450 return NULL;
451 451
452 /* return error information */ 452 /* return error information */
453 *errnum = state->err; 453 if (errnum != NULL)
454 *errnum = state->err;
454 return state->msg == NULL ? "" : state->msg; 455 return state->msg == NULL ? "" : state->msg;
455} 456}
456 457