gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 0c69f02: Segfault in mesh interpolation correc


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 0c69f02: Segfault in mesh interpolation corrected
Date: Fri, 11 Nov 2016 20:32:12 +0000 (UTC)

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

    Segfault in mesh interpolation corrected
    
    When the input image is very small (about the same size as the mesh grid),
    then there will only be one mesh. Until now, the neighboring meshes would
    be checked in any case, so when there is only one mesh (no neighbors),
    there was a segmentation fault. With this commit, the neighboring meshes
    are only checked when `numngb' is not zero.
    
    This bug was reported by Nicolas Bouché, so the `THANKS' file was updated.
    
    This fixes bug #49588.
---
 THANKS     |    6 ++----
 lib/mesh.c |   30 ++++++++++++++++++------------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/THANKS b/THANKS
index 8d812b5..6a0f8c7 100644
--- a/THANKS
+++ b/THANKS
@@ -17,6 +17,7 @@ support in Gnuastro. The list is ordered alphabetically.
 
     Karl Berry                           address@hidden
     Roland Bacon                         address@hidden
+    Nicolas Bouché                       address@hidden
     Antonio Diaz Diaz                    address@hidden
     Takashi Ichikawa                     address@hidden
     Brandon Invergo                      address@hidden
@@ -31,10 +32,7 @@ support in Gnuastro. The list is ordered alphabetically.
 Institutions
 ------------
 
-GNU Astronomy Utilities (Gnuastro) has greatly benefited from the following
-institutions. These institutions have either funded, supported and most
-importantly provided a productive environment for the developers of
-Gnuastro. The list is in chronological order.
+Host institutions of Gnuastro's developers.
 
     Ministry of education, culture, sports, science and technology, Japan.
     Tohoku University, Sendai, Japan.
diff --git a/lib/mesh.c b/lib/mesh.c
index 6d772e3..9f56bc4 100644
--- a/lib/mesh.c
+++ b/lib/mesh.c
@@ -1081,8 +1081,8 @@ meshinterponthread(void *inparams)
   size_t is1=mp->fullinterpolation ? mp->gs1*mp->nch1 : mp->gs1;
 
   /* Variables for this function: */
-  struct gal_linkedlist_tosll *lQ, *sQ;
   int ngarrays=mp->ngarrays;
+  struct gal_linkedlist_tosll *lQ, *sQ;
   size_t xc, yc, *n, *nf, currentnum, thisind;
   unsigned char *byt=&mp->byt[mtp->id*is0*is1];
   float *nearest1=&mp->nearest1[mtp->id*numnearest];
@@ -1092,7 +1092,6 @@ meshinterponthread(void *inparams)
   float *outgarray1=mp->outgarray1, *outgarray2=mp->outgarray2;
   float *nearest2 = ngarrays==2 ? &mp->nearest2[mtp->id*numnearest] : NULL;
 
-
   /* Go over all the meshes for this thread. */
   for(i=0;indexs[i]!=GAL_THREADS_NON_THRD_INDEX;++i)
     {
@@ -1156,16 +1155,23 @@ meshinterponthread(void *inparams)
           /* Check the four neighbors and if they have not already
              been checked, put them into the queue. */
           GAL_NEIGHBORS_FILL_4_ALLIMG;
-          nf=(n=ngb)+numngb;
-          do
-            if(byt[*n]==0)
-              {
-                byt[*n]=1;
-                gal_linkedlist_add_to_tosll_end(&lQ, &sQ, *n,
-                                                manhattandistance(*n, xc,
-                                                                  yc, is1));
-              }
-          while(++n<nf);
+
+          /* It might happen that there are no neighbors (e.g., that there
+             is only one mesh). In that case, we shouldn't look into the
+             neighbors.*/
+          n=ngb;
+          nf = numngb ? n+numngb : n;
+          while(n<nf)
+            {
+              if(byt[*n]==0)
+                {
+                  byt[*n]=1;
+                  gal_linkedlist_add_to_tosll_end(&lQ, &sQ, *n,
+                                                  manhattandistance(*n, xc,
+                                                                    yc, is1));
+                }
+              ++n;
+            }
 
           /* If there are no more meshes to add to the queue, then
              this shows, there were not enough points for



reply via email to

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