gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master b91fa6f 1/3: gal_statistics_is_sorted: not par


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master b91fa6f 1/3: gal_statistics_is_sorted: not parsing dataset of one element size
Date: Mon, 11 Mar 2019 16:54:23 -0400 (EDT)

branch: master
commit b91fa6fc760e50ada4b3dae0b1d3eebf2b31f0bb
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    gal_statistics_is_sorted: not parsing dataset of one element size
    
    When implementing this function, I had forgot to add a `break' after the
    case of a one-element dataset. As a result, a segmentation fault would be
    created when the input dataset only has one element. With this commit, this
    bug is fixed.
---
 doc/gnuastro.texi | 4 ++--
 lib/statistics.c  | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 0da2040..6e94ddb 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -28441,7 +28441,8 @@ plot (with a maximum of one).
 Return @code{0} if the input is not sorted, if it is sorted, this function
 will return @code{1} and @code{2} if it is increasing or decreasing,
 respectively. This function will abort with an error if @code{input} has
-zero elements. This function will only look into the dataset if the
+zero elements and will return @code{1} (sorted, increasing) when there is
+only one element. This function will only look into the dataset if the
 @code{GAL_DATA_FLAG_SORT_CH} bit of @code{input->flag} is @code{0}, see
 @ref{Generic data container}.
 
@@ -28461,7 +28462,6 @@ there are no other flags, you can simply set the flags 
to zero (with
 @example
 input->flags &= ~GAL_DATA_FLAG_SORT_CH;
 @end example
-
 @end deftypefun
 
 @deftypefun void gal_statistics_sort_increasing (gal_data_t @code{*input})
diff --git a/lib/statistics.c b/lib/statistics.c
index 4354261..685d73c 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -1206,8 +1206,9 @@ gal_statistics_is_sorted(gal_data_t *input, int 
updateflags)
        increasing. */
     case 1:
       out=STATISTICS_IS_SORTED_INCREASING;
+      break;
 
-    /* Do the check. */
+    /* Do the check when there is more than one element. */
     default:
       switch(input->type)
         {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]