changeset 10270:07cc8060be81 8u201-b02

8157913: Launcher can not find path to libpackager.so Reviewed-by: kcr
author almatvee
date Thu, 25 Oct 2018 14:14:18 -0700
parents b9d708bf38c9
children a93f39876d35
files modules/fxpackager/src/main/native/launcher/linux/launcher.cpp modules/fxpackager/src/main/native/library/common/LinuxPlatform.cpp
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/fxpackager/src/main/native/launcher/linux/launcher.cpp	Mon Oct 29 08:38:05 2018 -0700
+++ b/modules/fxpackager/src/main/native/launcher/linux/launcher.cpp	Thu Oct 25 14:14:18 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates.
  * All rights reserved. Use is subject to license terms.
  *
  * This file is available and licensed under the following license:
@@ -45,16 +45,14 @@
 #define MAX_PATH 1024
 
 std::string GetProgramPath() {
+    size_t len = 0;
     std::string result;
-    char *buffer = new char[MAX_PATH];
+    char buffer[MAX_PATH] = {0};
 
-    if (buffer != NULL) {
-        if (readlink("/proc/self/exe", buffer, MAX_PATH - 1) != -1) {
-            buffer[MAX_PATH - 1] = '\0';
-            result = buffer;
-        }
+    if ((len = readlink("/proc/self/exe", buffer, MAX_PATH - 1)) != -1) {
+        buffer[len] = '\0';
 
-        delete[] buffer;
+        result = buffer;
     }
 
     return result;
--- a/modules/fxpackager/src/main/native/library/common/LinuxPlatform.cpp	Mon Oct 29 08:38:05 2018 -0700
+++ b/modules/fxpackager/src/main/native/library/common/LinuxPlatform.cpp	Thu Oct 25 14:14:18 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates.
  * All rights reserved. Use is subject to license terms.
  *
  * This file is available and licensed under the following license:
@@ -84,10 +84,12 @@
 }
 
 TString LinuxPlatform::GetModuleFileName() {
+    size_t len = 0;
     TString result;
     DynamicBuffer<TCHAR> buffer(MAX_PATH);
 
-    if (readlink("/proc/self/exe", buffer.GetData(), MAX_PATH - 1) != -1) {
+    if ((len = readlink("/proc/self/exe", buffer.GetData(), MAX_PATH - 1)) != -1) {
+        buffer[len] = '\0';
         result = buffer.GetData();
     }