diff --git a/libs/main/io_devices/pifile.cpp b/libs/main/io_devices/pifile.cpp index f9ed991d..42953eca 100644 --- a/libs/main/io_devices/pifile.cpp +++ b/libs/main/io_devices/pifile.cpp @@ -181,7 +181,7 @@ bool PIFile::openTemporary(PIIODevice::DeviceMode mode) { } #else char template_rc[] = "/tmp/pifile_tmp_XXXXXX"; - int fd = mkstemp(template_rc); + int fd = mkstemp(template_rc); if (fd == -1) return false; ::close(fd); tp = template_rc; @@ -256,8 +256,11 @@ PIByteArray PIFile::readAll(bool forceRead) { llong cp = pos(); if (forceRead) { seekToBegin(); - while (!isEnd()) - a.push_back(readChar()); + for (;;) { + uchar byte = static_cast(fgetc(PRIVATE->fd)); + if (feof(PRIVATE->fd) || ferror(PRIVATE->fd)) break; + a.push_back(byte); + } seek(cp); return a; }