--- mtr-0.75/net.c      2008-09-19 11:37:57.000000000 +0200
+++ mtr-0.75/net.c      2008-10-10 20:52:32.000000000 +0200
@@ -3,9 +3,8 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+    it under the terms of the GNU General Public License version 2 as 
+    published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -898,11 +897,14 @@
   return 0;
 }
 
+
 static void set_fd_flags(int fd)
 {
 #if defined(HAVE_FCNTL) && defined(FD_CLOEXEC)
   int oldflags;
 
+  if (fd < 0) return; 
+
   oldflags = fcntl(fd, F_GETFD);
   if (oldflags == -1) {
     perror("Couldn't get fd's flags");
@@ -945,8 +947,9 @@
   set_fd_flags(recvsock4);
 #ifdef ENABLE_IPV6
   recvsock6 = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
+  if (recvsock6 >= 0)
+     set_fd_flags(recvsock6);
 #endif
-  set_fd_flags(recvsock6);
 
   return 0;
 }
