Commit 0b96f889 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*fixed segfault at start-up due to faulty allocation of the string length for...

*fixed segfault at start-up due to faulty allocation of the string length for checking for unique instance of pd-l2ork
*made unique check in more robust in respect to relative paths and multiple files by making sure that the script always goes back to the original directory from which it was invoked, so as to ensure that the path (if relative) is valid
parent 43ec4b4b
......@@ -8461,14 +8461,16 @@ proc pdtk_open_files_via_unique {filenames} {
proc pdtk_check_unique {unique filenames} {
#puts stderr "pdtk_check_unique $unique $filenames"
global appname
set startup_dir [pwd]
if { $unique == 0 } {
foreach file $filenames {
#puts stderr $file
cd [file dirname $file]
#puts stderr "$file [file dirname $file] $startup_dir"
catch {cd [file dirname $file]}
set dir [pwd]
set name [file tail $file]
#puts stderr "********DIR:$dir FILE:$name COMBINED:[file join $dir $name]"
lappend final_filenames [file join $dir $name]
cd $startup_dir
#puts stderr "send pd-l2ork pdtk_open_files_via_unique $final_filenames"
set outcome [catch {send pd-l2ork pdtk_open_files_via_unique \{$final_filenames\}}]
......@@ -309,7 +309,11 @@ int sys_main(int argc, char **argv)
int length = 0;
t_namelist *nl;
for (nl = sys_openlist; nl; nl = nl->nl_next)
length = length + strlen(nl->nl_string) + 1;
// for starting and ending quotes plus a space or null terminating
// character, we add 3 additional characters per entry
length = length + strlen(nl->nl_string) + 3;
if((filenames = malloc(length)) != NULL)
filenames[0] = '\0'; // ensures the memory is an empty string
......@@ -321,7 +325,7 @@ int sys_main(int argc, char **argv)
if (nl->nl_next)
strcat(filenames,"\" \"");
else strcat(filenames,"\"");
else strcat(filenames,"\"\0"); // ensures proper termination
//fprintf(stderr,"final list: <%s>\n", filenames);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment