In archive_read_open(), do not set the internal archive state to
"HEADER" unless the open is successful. Instead, leave the state as "NEW." In particular, if archive_read_open() fails, a subsequent call to archive_read_next_header() will now cause an explicit assertion failure instead of a silent segmentation fault. This may need a little more work to fully realize the intention: If archive_read_open() fails, you should be able to call it again on the same archive handle to open a different archive (or the same archive using a different mechanism).
This commit is contained in:
parent
3cf09dd123
commit
3be7274eed
@ -126,8 +126,6 @@ archive_read_open(struct archive *a, void *client_data,
|
||||
a->client_closer = closer;
|
||||
a->client_data = client_data;
|
||||
|
||||
a->state = ARCHIVE_STATE_HEADER;
|
||||
|
||||
/* Open data source. */
|
||||
if (a->client_opener != NULL) {
|
||||
e =(a->client_opener)(a, a->client_data);
|
||||
@ -156,6 +154,10 @@ archive_read_open(struct archive *a, void *client_data,
|
||||
|
||||
/* Initialize decompression routine with the first block of data. */
|
||||
e = (a->decompressors[high_bidder].init)(a, buffer, bytes_read);
|
||||
|
||||
if (e == ARCHIVE_OK)
|
||||
a->state = ARCHIVE_STATE_HEADER;
|
||||
|
||||
return (e);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user