Skip to content

Commit

Permalink
Check return of lseek() when creating bitPackedFile with offset.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwalenz committed Nov 22, 2016
1 parent cdc0d80 commit dcb630e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/AS_UTL/bitPackedFile.C
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ bitPackedFile::bitPackedFile(char const *name, uint64 offset, bool forceTruncate
// Move to the correct position in the file.
//
file_offset = offset;
if (file_offset > 0)
if (file_offset > 0) {
errno = 0;
lseek(_file, file_offset, SEEK_SET);
if (errno)
fprintf(stderr, "bitPackedFile::bitPackedFile()-- '%s' failed to seed to position %llu: %s\n", _name, file_offset, strerror(errno)), exit(1);
}

// Deal with endianess. We write out some bytes (or read back some bytes) to the start of
// the file, and then hide them from the user.
Expand Down

0 comments on commit dcb630e

Please sign in to comment.