qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT 4d22419] fix PATH_MAX conditional compilation


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT 4d22419] fix PATH_MAX conditional compilation
Date: Wed, 09 Sep 2009 22:36:59 -0000

From: Jean-Christophe DUBOIS <address@hidden>

PATH_MAX is used elsewhere in the qemu source tree without protection.

In addtion the actual code would not compile if PATH_MAX is not defined

Last the free() call is wrong as p is not malloc()ed.

Signed-off-by: Jean-Christophe Dubois <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/vl.c b/vl.c
index 215132a..6d535b9 100644
--- a/vl.c
+++ b/vl.c
@@ -4625,9 +4625,7 @@ static char *find_datadir(const char *argv0)
     char *dir;
     char *p = NULL;
     char *res;
-#ifdef PATH_MAX
     char buf[PATH_MAX];
-#endif
     size_t max_len;
 
 #if defined(__linux__)
@@ -4652,10 +4650,7 @@ static char *find_datadir(const char *argv0)
     /* If we don't have any way of figuring out the actual executable
        location then try argv[0].  */
     if (!p) {
-#ifdef PATH_MAX
-        p = buf;
-#endif
-        p = realpath(argv0, p);
+        p = realpath(argv0, buf);
         if (!p) {
             return NULL;
         }
@@ -4674,9 +4669,7 @@ static char *find_datadir(const char *argv0)
             res = NULL;
         }
     }
-#ifndef PATH_MAX
-    free(p);
-#endif
+
     return res;
 }
 #undef SHARE_SUFFIX




reply via email to

[Prev in Thread] Current Thread [Next in Thread]