aboutsummaryrefslogtreecommitdiff
path: root/gzlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'gzlib.c')
-rw-r--r--gzlib.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gzlib.c b/gzlib.c
index c10fabb..e4ca576 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -541,7 +541,8 @@ const char * ZEXPORT gzerror(file, errnum)
541 /* return error information */ 541 /* return error information */
542 if (errnum != NULL) 542 if (errnum != NULL)
543 *errnum = state->err; 543 *errnum = state->err;
544 return state->msg == NULL ? "" : state->msg; 544 return state->err == Z_MEM_ERROR ? "out of memory" :
545 (state->msg == NULL ? "" : state->msg);
545} 546}
546 547
547/* -- see zlib.h -- */ 548/* -- see zlib.h -- */
@@ -592,16 +593,13 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
592 if (msg == NULL) 593 if (msg == NULL)
593 return; 594 return;
594 595
595 /* for an out of memory error, save as static string */ 596 /* for an out of memory error, return literal string when requested */
596 if (err == Z_MEM_ERROR) { 597 if (err == Z_MEM_ERROR)
597 state->msg = (char *)msg;
598 return; 598 return;
599 }
600 599
601 /* construct error message with path */ 600 /* construct error message with path */
602 if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) { 601 if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
603 state->err = Z_MEM_ERROR; 602 state->err = Z_MEM_ERROR;
604 state->msg = (char *)"out of memory";
605 return; 603 return;
606 } 604 }
607#if !defined(NO_snprintf) && !defined(NO_vsnprintf) 605#if !defined(NO_snprintf) && !defined(NO_vsnprintf)