# [PATCH] git-send-email.perl: ensure $domain is defined before using it

2 messages from 2010-09-27 to 2010-09-27. Participants: Brandon Casey, Junio C Hamano.
Thread: https://gitlist.dev/t/25255

## Brandon Casey, 2010-09-27 03:18

Subject: [PATCH] git-send-email.perl: ensure $domain is defined before using it
Message-ID: <1285557481-16357-1-git-send-email-drafnel@gmail.com>
URL: https://gitlist.dev/e/1285557481-16357-1-git-send-email-drafnel%40gmail.com

```
valid_fqdn() may attempt to operate on an undefined value if
Net::Domain::domainname fails to determine the domain name.  This causes
perl to emit unpleasant warnings.

So, add a check for whether $domain has been defined before using it.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 6dab3bf..e1f29a7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -895,7 +895,7 @@ sub sanitize_address {
 
 sub valid_fqdn {
 	my $domain = shift;
-	return !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./;
+	return defined $domain && !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./;
 }
 
 sub maildomain_net {
-- 
1.7.3.1.geb284

```

## Junio C Hamano, 2010-09-27 22:19

Subject: Re: [PATCH] git-send-email.perl: ensure $domain is defined before using it
Message-ID: <7vhbhax20z.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vhbhax20z.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1285557481-16357-1-git-send-email-drafnel@gmail.com>

```
Thanks.

```
