Skip to content

Commit

Permalink
unrar_iface: unrar_open cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRaynMan committed Aug 7, 2013
1 parent 884b2e7 commit 8bbde69
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions libclamunrar_iface/unrar_iface.c
Expand Up @@ -314,21 +314,14 @@ int unrar_open(int fd, const char *dirname, unrar_state_t *state)
unrar_comment_header_t *comment_header;
unrar_dbgmsg("UNRAR: RAR main comment\n");
offset = lseek(fd, 0, SEEK_CUR);
if (offset == -1) {
unrar_dbgmsg("UNRAR: seek: lseek() call failed in unrar_open\n");
free(main_hdr);
free(state->comment_dir);
free(unpack_data);
return UNRAR_ERR;
}
if (offset == -1) {
unrar_dbgmsg("UNRAR: seek: lseek() call failed in unrar_open\n");
free(main_hdr);
free(state->comment_dir);
free(unpack_data);
return UNRAR_ERR;
}
unrar_dbgmsg("UNRAR: Offset: %x\n", offset);
if(offset < 0){
unrar_dbgmsg("UNRAR: Error Offset: %d\n", offset);
free(main_hdr);
free(state->comment_dir);
free(unpack_data);
return UNRAR_ERR;
}
comment_header = read_header(fd, COMM_HEAD);
if(comment_header) {
unrar_dbgmsg("UNRAR: Comment type: 0x%.2x\n", comment_header->head_type);
Expand Down Expand Up @@ -363,16 +356,16 @@ int unrar_open(int fd, const char *dirname, unrar_state_t *state)
}
free(comment_header);
}
if (lseek(fd, offset, SEEK_SET) == -1) {
unrar_dbgmsg("UNRAR: seek: call to lseek() failed in unrar_open: %ld\n", offset);
free(main_hdr);
ppm_destructor(&unpack_data->ppm_data);
rar_init_filters(unpack_data);
unpack_free_data(unpack_data);
free(unpack_data);
free(state->comment_dir);
return UNRAR_ERR;
}
if (lseek(fd, offset, SEEK_SET) == -1) {
unrar_dbgmsg("UNRAR: seek: call to lseek() failed in unrar_open: %ld\n", offset);
free(main_hdr);
ppm_destructor(&unpack_data->ppm_data);
rar_init_filters(unpack_data);
unpack_free_data(unpack_data);
free(unpack_data);
free(state->comment_dir);
return UNRAR_ERR;
}
}

if(main_hdr->head_size > SIZEOF_NEWMHD) {
Expand Down

0 comments on commit 8bbde69

Please sign in to comment.