gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 12f0653: Warp: sanity check when option value


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 12f0653: Warp: sanity check when option value is empty string
Date: Fri, 31 May 2019 20:24:15 -0400 (EDT)

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

    Warp: sanity check when option value is empty string
    
    Until now, when the value to individual warp options was an empty string,
    it would crash with a segmentation fault. With this commit, a check has
    been added so in such cashes it aborts with a reason.
    
    This fixes bug #56424.
---
 NEWS          | 1 +
 bin/warp/ui.c | 3 +++
 lib/options.c | 4 +++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 97b8c14..d14635a 100644
--- a/NEWS
+++ b/NEWS
@@ -87,6 +87,7 @@ See the end of the file for license conditions.
   bug #56257: ConvertType: Values not preserved when converting text to FITS.
   bug #56299: cosmiccal fails at z=0.
   bug #56324: Column metadata not usable when input is from pipe/stdin.
+  bug #56424: Warp crashes with empty string given to options.
 
 
 
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index 3c09b7d..1706d05 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -224,6 +224,9 @@ ui_add_to_modular_warps_ll(struct argp_option *option, char 
*arg,
   gal_data_t *new;
   struct warpparams *p=(struct warpparams *)params;
 
+  /* Make sure we actually have a string to parse. */
+  if(*arg=='\0')
+    error(EXIT_FAILURE, 0, "empty string given to `--%s'", option->name);
 
   /* Parse the (possible) arguments. */
   if(option->key==UI_KEY_ALIGN)
diff --git a/lib/options.c b/lib/options.c
index 58becc6..71bbd40 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -575,12 +575,14 @@ gal_options_parse_list_of_numbers(char *string, char 
*filename, size_t lineno)
   gal_list_f64_t *list=NULL, *tdll;
   double numerator=NAN, denominator=NAN, tmp;
 
-
   /* The nature of the arrays/numbers read here is very small, so since
      `p->cp.minmapsize' might not have been read yet, we will set it to -1
      (largest size_t number), so the values are kept in memory. */
   size_t minmapsize=-1;
 
+  /* If we have an empty string, just return NULL. */
+  if(*string=='\0') return NULL;
+
   /* Go through the input character by character. */
   while(string && *c!='\0')
     {



reply via email to

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