[36500] trunk/base/src/cregistry/registry.c

raimue at macports.org raimue at macports.org
Sun May 4 10:09:56 PDT 2008


Revision: 36500
          http://trac.macosforge.org/projects/macports/changeset/36500
Author:   raimue at macports.org
Date:     2008-05-04 10:09:55 -0700 (Sun, 04 May 2008)

Log Message:
-----------
cregistry/registry.c:
Fix build error. dirname(3) might change the passed argument, therefore we need
to strdup() the const char *path first.

Modified Paths:
--------------
    trunk/base/src/cregistry/registry.c

Modified: trunk/base/src/cregistry/registry.c
===================================================================
--- trunk/base/src/cregistry/registry.c	2008-05-04 16:45:20 UTC (rev 36499)
+++ trunk/base/src/cregistry/registry.c	2008-05-04 17:09:55 UTC (rev 36500)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <libgen.h>
+#include <string.h>
 #include <stdarg.h>
 #include <sqlite3.h>
 #include <sys/stat.h>
@@ -161,9 +162,12 @@
     if (stat(path, &sb) != 0) {
         initialized = 0;
         if (errno == ENOENT) {
-            if (stat(dirname(path), &sb) != 0) {
+            char *mypath = strdup(path);
+            mypath = dirname(mypath);
+            if (stat(mypath, &sb) != 0) {
                 can_write = 0;
             }
+            free(mypath);
         } else {
             can_write = 0;
         }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080504/384059e2/attachment.html


More information about the macports-changes mailing list