From 27f37c9cc16eaaf7b2b46b39ded1a415491489b8 Mon Sep 17 00:00:00 2001 From: peri4 Date: Fri, 15 Aug 2025 18:32:21 +0300 Subject: [PATCH] fix PIFile::readAll(force = true) --- libs/main/io_devices/pifile.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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; }