the_Foundation [main]

Linux: Fixed checking the executable path

=> e48ccd9e9681d7fc5d73ad0479898282f68d78fa

diff --git a/src/commandline.c b/src/commandline.c
index bd3b43b..c82cf03 100644
--- a/src/commandline.c
+++ b/src/commandline.c
@@ -32,6 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include 
 
+#if defined (iPlatformLinux)
+#  include 
+#endif
+
 iDeclareType(DefinedArg)
 iDeclareStaticClass(DefinedArg)
 
@@ -153,8 +157,9 @@ iString *readSymlinkTarget_(const iString *path) {
     resize_Block(buf, 64);
     for (;;) {
         ssize_t rc = readlink(cstr_String(path), data_Block(buf), size_Block(buf));
-        if (rc == -1) {
-            break;  /* failure */
+        if (rc == -1) { /* failure */
+            delete_String(target);
+            return NULL;
         } else if (rc <= size_Block(buf)) {
             break;
         }
@@ -185,6 +190,7 @@ void init_CommandLine(iCommandLine *d, int argc, char **argv) {
         appendCStr_String(d->execPath, ".exe");
     }
 #else
+    d->execPath = NULL;
 #   if defined (iPlatformLinux)
     if (access("/proc", F_OK) == 0) {
         /* The kernel provides a symbolic link to the executable's path. */
@@ -198,7 +204,9 @@ void init_CommandLine(iCommandLine *d, int argc, char **argv) {
     /* TODO: This does not work if the executable was started via PATH. It
        would be more reliable to use platform-specific means to determine the
        path. See: https://stackoverflow.com/a/1024937 */
-    d->execPath = makeAbsolute_Path(constFront_StringList(&d->args));
+    if (!d->execPath) {
+        d->execPath = makeAbsolute_Path(constFront_StringList(&d->args));
+    }
 #endif
 }
 
Proxy Information
Original URL
gemini://git.skyjake.fi/the_Foundation/main/cdiff/e48ccd9e9681d7fc5d73ad0479898282f68d78fa
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
62.324013 milliseconds
Gemini-to-HTML Time
0.177794 milliseconds

This content has been proxied by September (3851b).