bug-lilypond
[Top][All Lists]
Advanced

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

[PATCH] Fix unset PATH crash


From: Masamichi HOSODA
Subject: [PATCH] Fix unset PATH crash
Date: Sun, 01 Mar 2015 18:07:39 +0900 (JST)

On Windows, lilypond crashes when the environment variable PATH is not set.

```
C:\tmp\lilypond-2.19.16-0.mingw\$_OUTDIR\usr\bin>set PATH=

C:\tmp\lilypond-2.19.16-0.mingw\$_OUTDIR\usr\bin>lilypond
GNU LilyPond 2.19.16
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\tmp\lilypond-2.19.16-0.mingw\$_OUTDIR\usr\bin>
```

Even in the case of linux, this issue is a possible crash.
A patch file is attached.
>From 68e233c11b3eeaad0ee442a4b3a47e206ebc70e0 Mon Sep 17 00:00:00 2001
From: Masamichi Hosoda <address@hidden>
Date: Sun, 1 Mar 2015 17:44:54 +0900
Subject: [PATCH] Fix unset PATH crash

When the environment variable PATH is not set,
getenv ("PATH") returns NULL.
File_path::parse_path converts the argument into std::string.
To convert NULL into std::string raises an exception.

This patch check the return value of getenv ("PATH")
and pass to the File_path::parse_path only when it is not NULL.
---
 lily/relocate.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lily/relocate.cc b/lily/relocate.cc
index 2adfb6f..73fde03 100644
--- a/lily/relocate.cc
+++ b/lily/relocate.cc
@@ -181,7 +181,9 @@ setup_paths (char const *argv0_ptr)
         {
           /* Find absolute ARGV0 name, using PATH.  */
           File_path path;
-          path.parse_path (getenv ("PATH"));
+          char *p = getenv ("PATH");
+          if (p)
+            path.parse_path (p);
 
 #ifndef __MINGW32__
           argv0_abs = path.find (argv0_filename.to_string ());
-- 
2.1.4


reply via email to

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