summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2012-09-29 21:48:18 -0700
committerMark Adler <madler@alumni.caltech.edu>2012-09-29 22:37:55 -0700
commitbd143f1c0a24075b2ec063a91f7b2b4b3b3b6ad8 (patch)
treeae35744382b9c44b4261106ce206c0c7e712b4ad /examples
parentaa566e86c46d2264bf623e51f5840bde642548ad (diff)
downloadzlib-bd143f1c0a24075b2ec063a91f7b2b4b3b3b6ad8.tar.gz
Fix memory allocation error in examples/zran.c [Nor].
Diffstat (limited to 'examples')
-rw-r--r--examples/zran.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/zran.c b/examples/zran.c
index 617a130..278f9ad 100644
--- a/examples/zran.c
+++ b/examples/zran.c
@@ -1,7 +1,12 @@
/* zran.c -- example of zlib/gzip stream indexing and random access
- * Copyright (C) 2005 Mark Adler
+ * Copyright (C) 2005, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
- Version 1.0 29 May 2005 Mark Adler */
+ Version 1.1 29 Sep 2012 Mark Adler */
+
+/* Version History:
+ 1.0 29 May 2005 First version
+ 1.1 29 Sep 2012 Fix memory reallocation error
+ */
/* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
for random access of a compressed file. A file containing a zlib or gzip
@@ -221,7 +226,7 @@ local int build_index(FILE *in, off_t span, struct access **built)
/* clean up and return index (release unused entries in list) */
(void)inflateEnd(&strm);
- index = realloc(index, sizeof(struct point) * index->have);
+ index->list = realloc(index->list, sizeof(struct point) * index->have);
index->size = index->have;
*built = index;
return index->size;