File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -2753,20 +2753,31 @@ PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename) {
27532753 }
27542754 char buf [4096 ];
27552755 PyThread_acquire_lock (perf_map_state .map_lock , 1 );
2756- int fflush_result = 0 , result = 0 ;
2756+ int result = 0 ;
27572757 while (1 ) {
27582758 size_t bytes_read = fread (buf , 1 , sizeof (buf ), from );
2759+ if (bytes_read == 0 ) {
2760+ if (ferror (from )) {
2761+ result = -1 ;
2762+ }
2763+ break ;
2764+ }
2765+
27592766 size_t bytes_written = fwrite (buf , 1 , bytes_read , perf_map_state .perf_map );
2760- fflush_result = fflush (perf_map_state .perf_map );
2761- if (fflush_result != 0 || bytes_read == 0 || bytes_written < bytes_read ) {
2767+ if (bytes_written < bytes_read ) {
27622768 result = -1 ;
2763- goto close_and_release ;
2769+ break ;
27642770 }
2771+
2772+ if (fflush (perf_map_state .perf_map ) != 0 ) {
2773+ result = -1 ;
2774+ break ;
2775+ }
2776+
27652777 if (bytes_read < sizeof (buf ) && feof (from )) {
2766- goto close_and_release ;
2778+ break ;
27672779 }
27682780 }
2769- close_and_release :
27702781 fclose (from );
27712782 PyThread_release_lock (perf_map_state .map_lock );
27722783 return result ;
You can’t perform that action at this time.
0 commit comments