Do not let realpath do the allocation: Mac OS X 10.5 had issues with the NULL argument 47/10247/2
Sylvestre Ledru [Fri, 18 Jan 2013 11:23:38 +0000 (12:23 +0100)]
Change-Id: I43fa4fb6b4b333380eff51c6e7c68332a62a8b27

scilab/modules/core/src/c/tmpdir.c

index 9f22943..a534aac 100644 (file)
@@ -130,9 +130,14 @@ void createScilabTMPDIR(void)
         }
 
         /* XXXXXX will be randomized by mkdtemp */
-        char *tmp_dir_strdup = realpath(tmp_dir, NULL); /* Copy to avoid to have the same buffer as input and output for sprintf */
+
+        char *tmp_dir_strdup[PATH_MAX];
+        char *res = realpath(tmp_dir, tmp_dir_strdup);
+        if (!res)
+        {
+            fprintf(stderr, _("Warning: Could not resolve the realpath of %s.\n"), tmp_dir);
+        }
         sprintf(tmp_dir, "%s/SCI_TMP_%d_XXXXXX", tmp_dir_strdup, (int) getpid());
-        free(tmp_dir_strdup);
 
         if (mkdtemp(tmp_dir) == NULL)
         {