[GRASS-SVN] r61421 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 28 00:12:03 PDT 2014


Author: mmetz
Date: 2014-07-28 00:12:03 -0700 (Mon, 28 Jul 2014)
New Revision: 61421

Modified:
   grass/trunk/lib/gis/flate.c
Log:
libgis: add sanity check for compression_level

Modified: grass/trunk/lib/gis/flate.c
===================================================================
--- grass/trunk/lib/gis/flate.c	2014-07-28 07:00:25 UTC (rev 61420)
+++ grass/trunk/lib/gis/flate.c	2014-07-28 07:12:03 UTC (rev 61421)
@@ -328,10 +328,13 @@
     c_stream.avail_out = buf_sz;
     c_stream.next_out = buf;
 
-    /* Initialize using default compression (usually 6) */
-    err = deflateInit(&c_stream, G__.compression_level < 0
-		      ? Z_DEFAULT_COMPRESSION
-		      : G__.compression_level);
+    /* Initialize */
+    /* Valid zlib compression levels -1 - 9 */
+    /* zlib default: Z_DEFAULT_COMPRESSION = -1, equivalent to 6 
+     * as used here, 1 gives the best compromise between speed and compression */
+    err = deflateInit(&c_stream,
+                      (G__.compression_level < -1 || G__.compression_level > 9) 
+		      ? 1 : G__.compression_level);
 
     /* If there was an error initializing, return -1 */
     if (err != Z_OK) {



More information about the grass-commit mailing list