[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 98a2ce4 3/5: Remove redundant strlen in src/ar
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 98a2ce4 3/5: Remove redundant strlen in src/arithmetic/arithmetic.c |
Date: |
Wed, 27 Jul 2016 12:41:09 +0000 (UTC) |
branch: master
commit 98a2ce4b9e8de9856f2814db92007faeaf0c90c5
Author: Vladimir Markelov <address@hidden>
Commit: Vladimir Markelov <address@hidden>
Remove redundant strlen in src/arithmetic/arithmetic.c
Function gal_fits_name_is_fits calls strlen inside it and returns
NULL in case of string is empty. Moreover strlen may crash if
an argument is NULL. That is why I replaced extra strlen with
checking the string against NULL.
This fixed bug #48571
---
src/arithmetic/arithmetic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arithmetic/arithmetic.c b/src/arithmetic/arithmetic.c
index 7cc3204..4ede5cb 100644
--- a/src/arithmetic/arithmetic.c
+++ b/src/arithmetic/arithmetic.c
@@ -74,7 +74,7 @@ add_operand(struct imgarithparams *p, char *filename, double
number,
newnode->number=number;
newnode->filename=filename;
- if(strlen(filename) && gal_fits_name_is_fits(filename))
+ if(filename != NULL && gal_fits_name_is_fits(filename))
{
/* Set the HDU for this filename. */
gal_linkedlist_pop_from_stll(&p->hdus, &newnode->hdu);