diff --git a/CHANGELOG.md b/CHANGELOG.md index d82f11269..63fb1e484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -## [5.0.56] - 2024-03-?? +## [5.0.56] - 2024-02-24 * set the ZeroMQ port to 0 by default, hence assuming a single-server mode (the port can be specified in the _*config.ini*_ file) +* corrected the P-V Diagram line length calculation inside a FORTRAN subroutine, added capacity checks to prevent potential out-of-bounds accesses ## [5.0.55] - 2024-02-22 diff --git a/Julia/pv_line.jl b/Julia/pv_line.jl deleted file mode 100644 index e2bc359fa..000000000 --- a/Julia/pv_line.jl +++ /dev/null @@ -1,17 +0,0 @@ -x1 = 100 -y1 = 98 -x2 = 98 -y2 = 95 - -dx = abs(x2 - x1) + 1 -dy = abs(y2 - y1) + 1 -dp = sqrt(dx^2 + dy^2) -dt = 1.0 / dp / 100.0 - -println("dx: $dx, dy: $dy, dp: $dp, dt: $dt") - -for t in 0:dt:1 - x = x1 + t * (x2 - x1) - y = y1 + t * (y2 - y1) - #println("($x, $y)") -end \ No newline at end of file diff --git a/src/fits.f90 b/src/fits.f90 index 7e0ef401e..6fe097fa5 100644 --- a/src/fits.f90 +++ b/src/fits.f90 @@ -8679,7 +8679,7 @@ recursive subroutine ws_pv_request(user) BIND(C, name='ws_pv_request') type(c_ptr) :: pid integer(kind=c_int) :: rc - integer :: frame, first, last, length, npoints, i, j, max_threads + integer :: frame, first, last, length, capacity, npoints, i, j, max_threads real :: dx, dy, dp, t, dt integer(c_int) :: x1, x2, y1, y2 integer :: prev_x, prev_y, cur_x, cur_y @@ -8762,8 +8762,8 @@ recursive subroutine ws_pv_request(user) BIND(C, name='ws_pv_request') print *, 'dx:', dx, 'dy:', dy, 'dp:', dp, 'dt:', dt ! over-allocate the points array - npoints = ceiling(2*dp) - allocate (points(2,npoints)) + capacity = ceiling(2*dp) + allocate (points(2,capacity)) ! first enumerate points along the line npoints = 0 @@ -8781,9 +8781,12 @@ recursive subroutine ws_pv_request(user) BIND(C, name='ws_pv_request') end if t = t + dt + + ! break the loop if capacity is exceeded + if (npoints .ge. capacity) exit end do - print *, 'npoints:', npoints + print *, 'npoints:', npoints, 'capacity:', capacity ! there will be at least one point ! allocate the pv array using an appropriate astronomical orientation convention @@ -8980,7 +8983,7 @@ subroutine get_pv_diagram(item, req, pixels, width, height, pmin, pmax, pmean, p type(c_ptr) :: pid integer(kind=c_int) :: rc - integer :: frame, first, last, length, i, j, max_threads + integer :: frame, first, last, length, i, j, max_threads, capacity real :: dx, dy, dp, t, dt integer(c_int) :: x1, x2, y1, y2 integer :: prev_x, prev_y, cur_x, cur_y @@ -9039,8 +9042,8 @@ subroutine get_pv_diagram(item, req, pixels, width, height, pmin, pmax, pmean, p print *, 'dx:', dx, 'dy:', dy, 'dp:', dp, 'dt:', dt ! over-allocate the points array - npoints = ceiling(2*dp) - allocate (points(2,npoints)) + capacity = ceiling(2*dp) + allocate (points(2,capacity)) ! first enumerate points along the line npoints = 0 @@ -9058,9 +9061,12 @@ subroutine get_pv_diagram(item, req, pixels, width, height, pmin, pmax, pmean, p end if t = t + dt + + ! break the loop if capacity is exceeded + if (npoints .ge. capacity) exit end do - print *, 'npoints:', npoints + print *, 'npoints:', npoints, 'capacity:', capacity ! there will be at least one point ! allocate the pv array using an appropriate astronomical orientation convention diff --git a/src/version.h b/src/version.h index 3182fc623..201245d37 100644 --- a/src/version.h +++ b/src/version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_SUB 55 +#define VERSION_SUB 56 #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x)