zlib 1.2.4-pre1

This commit is contained in:
Mark Adler
2011-09-09 23:32:36 -07:00
parent 7751bd4c71
commit 67cc20d004
67 changed files with 3311 additions and 3508 deletions

19
gzlib.c
View File

@@ -147,6 +147,14 @@ local gzFile gz_open(path, fd, mode)
return NULL;
}
/* save the path name for error messages */
state->path = malloc(strlen(path) + 1);
if (state->path == NULL) {
free(state);
return NULL;
}
strcpy(state->path, path);
/* open the file with the appropriate mode (or just use fd) */
state->fd = fd != -1 ? fd :
open(path,
@@ -170,14 +178,6 @@ local gzFile gz_open(path, fd, mode)
if (state->mode == GZ_APPEND)
state->mode = GZ_WRITE; /* simplify later checks */
/* save the path name for error messages */
state->path = malloc(strlen(path) + 1);
if (state->path == NULL) {
free(state);
return NULL;
}
strcpy(state->path, path);
/* save the current position for rewinding (only if reading) */
if (state->mode == GZ_READ) {
state->start = LSEEK(state->fd, 0, SEEK_CUR);
@@ -450,7 +450,8 @@ const char * ZEXPORT gzerror(file, errnum)
return NULL;
/* return error information */
*errnum = state->err;
if (errnum != NULL)
*errnum = state->err;
return state->msg == NULL ? "" : state->msg;
}