mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Fix seriously broken implementation of GetMagicNumber.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18422 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fc757b5217
commit
86ac2dcda1
@ -178,11 +178,13 @@ bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
|
|||||||
int fd = ::open(path.c_str(),O_RDONLY);
|
int fd = ::open(path.c_str(),O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
if (0 != ::read(fd, buf, len))
|
ssize_t bytes_read = ::read(fd, buf, len);
|
||||||
|
::close(fd);
|
||||||
|
if (ssize_t(len) != bytes_read) {
|
||||||
|
Magic.clear();
|
||||||
return false;
|
return false;
|
||||||
close(fd);
|
}
|
||||||
buf[len] = '\0';
|
Magic.assign(buf,len);
|
||||||
Magic = buf;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,11 +178,13 @@ bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
|
|||||||
int fd = ::open(path.c_str(),O_RDONLY);
|
int fd = ::open(path.c_str(),O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return false;
|
return false;
|
||||||
if (0 != ::read(fd, buf, len))
|
ssize_t bytes_read = ::read(fd, buf, len);
|
||||||
|
::close(fd);
|
||||||
|
if (ssize_t(len) != bytes_read) {
|
||||||
|
Magic.clear();
|
||||||
return false;
|
return false;
|
||||||
close(fd);
|
}
|
||||||
buf[len] = '\0';
|
Magic.assign(buf,len);
|
||||||
Magic = buf;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user