nsgml: Resolve symbol collision when building with SunStudio 12.1
[oweals/cde.git] / cde / programs / dtfile / SharedProcs.c
index eadcc2f97af06cecb7b1909971bc74983829d30b..1a4366634250c09175556cb4f36ab59fff538975 100644 (file)
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * 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
  */
@@ -234,9 +234,9 @@ _DtFollowLink (
 
    strcpy(file, path);
 
-   while ((link_len = readlink(file, link_path, MAXPATHLEN)) > 0)
+   while ((link_len = readlink(file, link_path, MAXPATHLEN - 1)) > 0)
    {
-      link_path[link_len-1] = 0;
+      link_path[link_len] = 0;
 
       /* Force the link to be an absolute path, if necessary */
       if (link_path[0] != '/')
@@ -393,7 +393,7 @@ _DtLoadSubdialogArray (
 
 {
    int i;
-   char number[10];
+   static char number[10];
 
    /* Load sub-dialogs */
    nameList[nameCount] = number;
@@ -404,7 +404,7 @@ _DtLoadSubdialogArray (
 
    for (i = 0; i < dialogCount; i++)
    {
-      sprintf(number, "%d", firstId);
+      snprintf(number, 10, "%d", firstId);
       (*dialogArray)[i] = _DtGetResourceDialogData(dialogId, dataBase, nameList);
       firstId++;
    }
@@ -423,14 +423,14 @@ _DtSaveSubdialogArray (
 
 {
    int i;
-   char number[10];
+   static char number[10];
 
    nameList[nameCount] = number;
    nameList[nameCount + 1] = NULL;
 
    for (i = 0; i < dialogCount; i++)
    {
-      sprintf(number, "%d", firstId);
+      snprintf(number, 10, "%d", firstId);
       _DtWriteDialogData(dialogArray[i], fd, nameList);
       firstId++;
    }
@@ -1348,7 +1348,7 @@ BuildBufferFileName (char   *file_name,
 /*
  * This is a function for building a buffer name using predfined input
  * and name template information from the types database.
- * WARNING: template_input will be freed. It must point to a char *.
+ * WARNING: template_input MAY be freed. It must point to a char *.
  */
 
 static char *
@@ -1378,6 +1378,7 @@ RetrieveAndUseNameTemplateInfo(
    }
    else
    {
+      DtDtsFreeAttributeValue(name_template);
       return(template_input);
    }
 }
@@ -1628,7 +1629,7 @@ _DtPathFromInput(
 
    /* Resolve, if there're any, environment variables */
    {
-      FILE *pfp;
+      FILE *pfp = NULL;
       char command[MAXPATHLEN];
 
       memset(command, 0, sizeof(command));
@@ -1650,7 +1651,7 @@ _DtPathFromInput(
                  sleep (1);
                  if (NULL != (fgets(command,MAXPATHLEN,pfp))) 
                      break;
-            }
+              }
             if (i >= 5)
                 read_ok = 0;
         }
@@ -1665,8 +1666,14 @@ _DtPathFromInput(
              XtFree(path);
              path = XtNewString(command);
              pclose(pfp);
+             pfp = NULL;
         }
       }
+      if (pfp)
+      {
+          pclose(pfp);
+          pfp = NULL;
+      }
    }
 
    /* Resolve '~' -- new memory is allocated, old memory is freed */