[syslinux] [PATCH 2/2] linux/syslinux.c: Test if null

Gene Cumm gene.cumm at gmail.com
Sat Jun 19 07:18:50 PDT 2010


Replaces previous patch.

From: Gene Cumm <gene.cumm at gmail.com>

linux/syslinux.c: Test if opt.directory is null before testing first
character or attempting to use it.

Signed-off-by: Gene Cumm <gene.cumm at gmail.com>

asprintf was converting a NULL opt.directory to the string "(null)".

---

diff --git a/linux/syslinux.c b/linux/syslinux.c
index 3a51f7e..8db9cdd 100644
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -283,7 +283,8 @@ int main(int argc, char *argv[])
     parse_options(argc, argv, MODE_SYSLINUX);

     ret = asprintf(&subdir, "%s%s",
-            opt.directory[0] == '/' ? "" : "/", opt.directory);
+            (opt.directory ? ((opt.directory[0] == '/') ? "" : "/") : ""),
+            (opt.directory ? opt.directory : ""));
     if (!subdir) {
        perror(program);
        exit(1);




More information about the Syslinux mailing list