gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master b67bd51: Crop: print message when image and WC


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master b67bd51: Crop: print message when image and WCS have differing dimensions
Date: Sun, 16 May 2021 22:11:10 -0400 (EDT)

branch: master
commit b67bd51288de2e4516e873523c048e2890a9260e
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Crop: print message when image and WCS have differing dimensions
    
    Until now, when the number of dimensions in the input image differed from
    the number of dimensions of the WCS (with the WCS having a larger number of
    dimensions) and WCS-based '--center' was given, Crop would crash with a
    "segmentation fault"! This happens in some Radio data pipelines where a 2D
    image has 4 WCS dimensions (the last two having zero length!).
    
    This was happening because we were reading the values to '--center' based
    on the number of dimensions in the WCS (while it was originally checked
    with the number of dimensions in the image). Therefore when the number of
    dimensions in the WCS was larger than the image, the program would attempt
    to read from space that was not allocated, causing a segmentation fault.
    
    With this commit, we now prepare the center positions based on the image
    dimensions (the same dimensions that we check with). Therfore when the
    dimensions differ, instead of an enigmatic "segmentation fault", a clear
    warning is printed by Gnuastro's WCS library that the number of dimensions
    differ. Its up to the user to fix this.
    
    This fixes bug #60619.
---
 NEWS          | 1 +
 bin/crop/ui.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index cd76386..4bb605e 100644
--- a/NEWS
+++ b/NEWS
@@ -252,6 +252,7 @@ See the end of the file for license conditions.
   bug #60483: No warning when file given to '--config' doesn't exist
   bug #60484: Match crashes when called with --coord and --ccol2 (together)
   bug #60603: Table crashes with an empty input and --range
+  bug #60619: Crop crashes with differing image and WCS dimension
 
 
 
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index 58a8a2f..4b28cb8 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -919,7 +919,7 @@ ui_preparations_to_img_mode_values(struct cropparams *p)
 
   int i, status, *stat=NULL;
   gal_data_t *tmp, *coords=NULL;
-  size_t ndim=wcs->naxis, plysize=p->nvertices;
+  size_t ndim=p->imgs[0].ndim, plysize=p->nvertices;
   double *phi=NULL, *theta=NULL, *pixcrd=NULL, *imgcrd=NULL;
 
   /* When central coordinates (either from '--center' or '--catalog' are



reply via email to

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