dtlogin: Two additional coverity fixes
[oweals/cde.git] / cde / programs / dtlogin / qualify.c
index 4a079f880db43dc36a5a8b4fdcb578a8216cbaea..9c743c729a833a46c495cfd431306ef6a299afad 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2012, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
 /* $XConsortium: qualify.c /main/3 1995/10/27 16:14:33 rswiston $ */
 /*                                                                      *
  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
@@ -7,6 +29,7 @@
  */
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 /*********************************************************************
  * qualifyWithFirst
@@ -26,8 +49,8 @@ char * qualifyWithFirst
   char * searchPath
   )
 {
-char * paths = strdup(searchPath);
-char * savepaths = paths;
+char * paths = NULL;
+char * savepaths = NULL;
 char * path;
 char * chance;
 FILE * f;
@@ -37,6 +60,9 @@ FILE * f;
   if (filename == NULL || searchPath == NULL)
     return NULL;
 
+  paths = strdup(searchPath);
+  savepaths = paths;
+
   while (1) {
 
     /* if there is a :, zero it */