Set returned index to NULL on an index build error in zran.c.
An attempt to use the returned pointer in deflate_index_extract() will now return cleanly with an error. The returned pointer can now also be used with deflate_index_free() even on error.
This commit is contained in:
parent
f1f503da85
commit
be4db0a79a
@ -130,6 +130,10 @@ static struct deflate_index *add_point(struct deflate_index *index, int bits,
|
||||
|
||||
// See comments in zran.h.
|
||||
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
|
||||
// If this returns with an error, any attempt to use the index will cleanly
|
||||
// return an error.
|
||||
*built = NULL;
|
||||
|
||||
// Set up inflation state.
|
||||
z_stream strm = {0}; // inflate engine (gets fired up later)
|
||||
unsigned char buf[CHUNK]; // input buffer
|
||||
|
@ -30,7 +30,7 @@ struct deflate_index {
|
||||
// the number of access points on success (>= 1), Z_MEM_ERROR for out of
|
||||
// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
|
||||
// or verification error in the input file, or Z_ERRNO for a file read error.
|
||||
// On success, *built points to the resulting index.
|
||||
// On success, *built points to the resulting index, otherwise it's NULL.
|
||||
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
|
||||
|
||||
// Use the index to read len bytes from offset into buf. Return the number of
|
||||
|
Loading…
Reference in New Issue
Block a user