aboutsummaryrefslogtreecommitdiff
path: root/zlibWrapper/gzwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'zlibWrapper/gzwrite.c')
-rw-r--r--zlibWrapper/gzwrite.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/zlibWrapper/gzwrite.c b/zlibWrapper/gzwrite.c
index d1250b90084d..21d5f84727aa 100644
--- a/zlibWrapper/gzwrite.c
+++ b/zlibWrapper/gzwrite.c
@@ -6,6 +6,8 @@
* For conditions of distribution and use, see http://www.zlib.net/zlib_license.html
*/
+#include <assert.h>
+
#include "gzguts.h"
/* Local functions */
@@ -24,7 +26,7 @@ local int gz_init(state)
z_streamp strm = &(state.state->strm);
/* allocate input buffer (double size for gzprintf) */
- state.state->in = (unsigned char *)malloc(state.state->want << 1);
+ state.state->in = (unsigned char*)malloc(state.state->want << 1);
if (state.state->in == NULL) {
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
@@ -33,7 +35,7 @@ local int gz_init(state)
/* only need output buffer and deflate state if compressing */
if (!state.state->direct) {
/* allocate output buffer */
- state.state->out = (unsigned char *)malloc(state.state->want);
+ state.state->out = (unsigned char*)malloc(state.state->want);
if (state.state->out == NULL) {
free(state.state->in);
gz_error(state, Z_MEM_ERROR, "out of memory");
@@ -284,6 +286,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
gz_statep state;
/* get internal structure */
+ assert(size != 0);
if (file == NULL)
return 0;
state = (gz_statep)file;
@@ -294,7 +297,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
/* compute bytes to read -- error on overflow */
len = nitems * size;
- if (size && len / size != nitems) {
+ if (size && (len / size != nitems)) {
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
return 0;
}