[Top][All Lists]

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

[gnuastro-commits] master 55a05b8: Upper-limit crash fixed on label in w

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 55a05b8: Upper-limit crash fixed on label in whole dimension
Date: Wed, 25 Oct 2017 10:50:50 -0400 (EDT)

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

    Upper-limit crash fixed on label in whole dimension
    When a given label in a dataset extends over a whole dimension, the random
    number generator would crash until now. The reason was that the size of the
    label along that dimension would be the same as the input's size,
    therefore, the difference minus one would be the largest possible unsigned
    type, which is much larger than the expected range of the integer random
    number generator.
    To fix the problem, when a label extends over a whole dimension, the value
    is now be fixed to zero (to only allow variation along other dimensions).
    This fixes bug #52281.
 NEWS                       | 2 ++
 bin/mkcatalog/upperlimit.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 2a00652..48266a9 100644
--- a/NEWS
+++ b/NEWS
@@ -102,6 +102,8 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   CFITSIO 3.42 and libcurl crash at Gnuastro configure time (bug #52152).
+  MakeCatalog crash in upper-limit with full size label (bug #52281).
 * Noteworthy changes in release 0.4 (library 2.0.0) (2017-09-13) [stable]
diff --git a/bin/mkcatalog/upperlimit.c b/bin/mkcatalog/upperlimit.c
index 0068b8f..44d4184 100644
--- a/bin/mkcatalog/upperlimit.c
+++ b/bin/mkcatalog/upperlimit.c
@@ -186,7 +186,9 @@ upperlimit_one_tile(struct mkcatalog_passparams *pp, 
gal_data_t *tile,
       /* Get the random coordinates, note that `gsl_rng_uniform_int'
          returns an inclusive value. */
-        rcoord[d] = gsl_rng_uniform_int(pp->rng, dsize[d]-tile->dsize[d]-1);
+        rcoord[d] = ( (dsize[d]-tile->dsize[d])
+                      ? gsl_rng_uniform_int(pp->rng, dsize[d]-tile->dsize[d]-1)
+                      : 0 );
       /* Set the tile's new starting pointer. */
       tile->array = gal_data_ptr_increment(p->input->array,

reply via email to

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