libDtHelp: Fix another regression caused by Coverity fix, clicking 'Help Manager...
[oweals/cde.git] / cde / programs / dtfile / Help.c
index 07d8ce2b0ded680b1e762a7a48f624ce20b9c091..ad3e95c073e85747b07d109f3c5d14a6dd001aec 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 libraries and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
 /* $XConsortium: Help.c /main/6 1996/10/29 17:08:14 mustafa $ */
 /************************************<+>*************************************
  ****************************************************************************
@@ -451,7 +473,7 @@ MapFileTypeToHelpString(
    char * desc;
    Boolean isAction;
    char * tmpStr;
-   char * label;
+   char * label = NULL;
 
    /* Special case for the 2 built in directory commands */
    if (strcmp(filetype, openNewView) == 0)
@@ -476,22 +498,21 @@ MapFileTypeToHelpString(
       return(buf);
    }
 
-#ifdef old
-   if (miscData)
-      /* The DtGetActionDescription function must be modified to
-         accept a non-integral second parameter.  (Filetypes are no
-         longer expressed as integers. */
-      desc = DtGetActionDescription(filetype, -1);
-   else
-#endif
-      desc = DtDtsDataTypeToAttributeValue(filetype,
-                                           DtDTS_DA_DESCRIPTION,
-                                           NULL);
+   desc = DtDtsDataTypeToAttributeValue(filetype,
+                                        DtDTS_DA_DESCRIPTION,
+                                        NULL);
 
    isAction = DtDtsDataTypeIsAction(filetype);
 
    if (desc)
-      return(XtNewString(desc));
+   {
+      char *descptr = XtNewString(desc);
+      XtFree((char *)desc);
+      if (descptr)
+         return descptr;
+      else
+         return NULL;
+   }
 
    /* No description found for this filetype */
    if (isAction)
@@ -514,6 +535,7 @@ MapFileTypeToHelpString(
        buf = XtMalloc(strlen(label) + strlen(helpPattern) + 100);
        sprintf(buf, helpPattern, label);
        DtDtsFreeAttributeValue(label);
+       label = NULL;
    }
    else
    {