gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 8b3e7ef: Crop: image mode can now account for


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 8b3e7ef: Crop: image mode can now account for no overlap
Date: Tue, 22 Oct 2019 15:26:18 -0400 (EDT)

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

    Crop: image mode can now account for no overlap
    
    Until now, when there was no overlap with the input image, in image-mode
    Crop would crash. This was because no FITS pointer would be created.
    
    With this commit, after defining the crop, if no FITS pointer is created,
    it will simply switch the `numimg' variable to zero and Crop will operate
    as expected.
    
    This fixes bug #57101.
---
 NEWS            | 1 +
 bin/crop/crop.c | 6 +++++-
 lib/fits.c      | 4 ++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index ae4a2ed..5cca4f3 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,7 @@ See the end of the file for license conditions.
   bug #56754: Wrong sigma clipping output when many values are equal.
   bug #56999: Compilation error on macOS 10.9 not recognizing AT_FDCWD.
   bug #57057: BuildProgram not using environment LDFLAGS or CPPFLAGS.
+  bug #57101: Crop segmentation fault when no overlap exists in image-mode.
 
 
 
diff --git a/bin/crop/crop.c b/bin/crop/crop.c
index 3e19f71..88802a9 100644
--- a/bin/crop/crop.c
+++ b/bin/crop/crop.c
@@ -224,6 +224,10 @@ crop_mode_img(void *inparam)
       /* Crop the image. */
       onecrop(crp);
 
+      /* If there was no overlap, then no FITS pointer is created, so
+         `numimg' should be set to zero. */
+      if(crp->outfits==NULL) crp->numimg=0;
+
       /* Check the final output: */
       if(crp->numimg)
         {
@@ -235,7 +239,7 @@ crop_mode_img(void *inparam)
           status=0;
           if( fits_close_file(crp->outfits, &status) )
             gal_fits_io_error(status, "CFITSIO could not close "
-                                   "the opened file");
+                              "the opened file");
 
           /* Remove the output image if its center was not filled. */
           if(crp->centerfilled==0)
diff --git a/lib/fits.c b/lib/fits.c
index 06f7381..82af7e0 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -1592,6 +1592,10 @@ gal_fits_key_write_version_in_ptr(gal_fits_list_key_t 
**keylist, char *title,
   const char *wcslibversion_const;
 #endif
 
+  /* Small sanity check. */
+  if(fptr==NULL)
+    error(EXIT_FAILURE, 0, "%s: input FITS pointer is NULL", __func__);
+
   /* If any header keywords are specified, add them: */
   if(keylist && *keylist)
     {



reply via email to

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