mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
fix OutputFile::seek() for SEEK_SET and SEEK_END
This commit is contained in:
parent
0a485eafcb
commit
549c59ecf5
11
src/file.cpp
11
src/file.cpp
|
@ -396,6 +396,17 @@ void OutputFile::rewrite(const void *buf, int len)
|
|||
void OutputFile::seek(off_t off, int whence)
|
||||
{
|
||||
assert(!opt->to_stdout);
|
||||
switch (whence) {
|
||||
case SEEK_SET: {
|
||||
if (bytes_written < off) {
|
||||
bytes_written = off;
|
||||
}
|
||||
_length = bytes_written; // cheap, lazy update; needed?
|
||||
} break;
|
||||
case SEEK_END: {
|
||||
_length = bytes_written; // necessary
|
||||
} break;
|
||||
}
|
||||
super::seek(off,whence);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user