diff --git a/src/file_nk2.c b/src/file_nk2.c index c103ae9c..ee1b31b7 100644 --- a/src/file_nk2.c +++ b/src/file_nk2.c @@ -109,16 +109,12 @@ static void file_check_nk2(file_recovery_t *fr) { nk2Header nk2h; unsigned int i; - fseek(fr->handle, 0, SEEK_SET); fr->file_size = 0; fr->offset_error=0; fr->offset_ok=0; - if (fread(&nk2h, sizeof(nk2h), 1, fr->handle)!=1) - { - fr->offset_error=fr->file_size; - fr->file_size=0; + if(fseek(fr->handle, 0, SEEK_SET) < 0 || + fread(&nk2h, sizeof(nk2h), 1, fr->handle)!=1) return; - } fr->file_size+=sizeof(nk2h); #ifdef DEBUG_NK2 log_info("nk2 item_count=%u\n", (unsigned int)le32(nk2h.items_count));