summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/sysmodule.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2026-02-07 19:56:35 +0300
committershadchin <[email protected]>2026-02-07 20:23:53 +0300
commit19d43a3e6fb4cb8ea11747d7d7bca7a3542fbb44 (patch)
tree0b1418938140a0b6470953bef6069454ffdf1bd0 /contrib/tools/python3/Python/sysmodule.c
parent0879409bfc0891ab8103828a3bdbf0e960475fec (diff)
Update Python 3 to 3.13.12
commit_hash:71d3efea437a769b2b7910d196120bb02587046e
Diffstat (limited to 'contrib/tools/python3/Python/sysmodule.c')
-rw-r--r--contrib/tools/python3/Python/sysmodule.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/contrib/tools/python3/Python/sysmodule.c b/contrib/tools/python3/Python/sysmodule.c
index cf06943c7c8..782c595d2ab 100644
--- a/contrib/tools/python3/Python/sysmodule.c
+++ b/contrib/tools/python3/Python/sysmodule.c
@@ -2609,20 +2609,31 @@ PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
}
char buf[4096];
PyThread_acquire_lock(perf_map_state.map_lock, 1);
- int fflush_result = 0, result = 0;
+ int result = 0;
while (1) {
size_t bytes_read = fread(buf, 1, sizeof(buf), from);
+ if (bytes_read == 0) {
+ if (ferror(from)) {
+ result = -1;
+ }
+ break;
+ }
+
size_t bytes_written = fwrite(buf, 1, bytes_read, perf_map_state.perf_map);
- fflush_result = fflush(perf_map_state.perf_map);
- if (fflush_result != 0 || bytes_read == 0 || bytes_written < bytes_read) {
+ if (bytes_written < bytes_read) {
result = -1;
- goto close_and_release;
+ break;
}
+
+ if (fflush(perf_map_state.perf_map) != 0) {
+ result = -1;
+ break;
+ }
+
if (bytes_read < sizeof(buf) && feof(from)) {
- goto close_and_release;
+ break;
}
}
-close_and_release:
fclose(from);
PyThread_release_lock(perf_map_state.map_lock);
return result;