Selaa lähdekoodia

Fix possible double call to inflateEnd.

svn:r4540
Nick Mathewson 19 vuotta sitten
vanhempi
commit
50e11ee16a
1 muutettua tiedostoa jossa 5 lisäystä ja 4 poistoa
  1. 5 4
      src/common/torgzip.c

+ 5 - 4
src/common/torgzip.c

@@ -147,6 +147,7 @@ tor_gzip_uncompress(char **out, size_t *out_len,
   struct z_stream_s *stream = NULL;
   size_t out_size;
   off_t offset;
+  int r;
 
   tor_assert(out);
   tor_assert(out_len);
@@ -202,15 +203,15 @@ tor_gzip_uncompress(char **out, size_t *out_len,
                stream->msg ? stream->msg : "<no message>");
         goto err;
       }
-
   }
  done:
   *out_len = stream->total_out;
-  if (inflateEnd(stream)!=Z_OK) {
+  r = inflateEnd(stream);
+  tor_free(stream);
+  if (r != Z_OK) {
     log_fn(LOG_WARN, "Error freeing gzip structures");
-    goto err; /* XXX this will try to inflateEnd again, right? is that bad? */
+    goto err;
   }
-  tor_free(stream);
 
   /* NUL-terminate output. */
   if (out_size == *out_len)