On Wed, 4 May 2022, Fred Engst wrote:
In this email I will only report the crash in reading a text file.
Here is the script that caused the crash:
string path = "path to my directory"
string filename = "TestCrashFile.txt"
string myname = path ~ filename
string fileread = readfile(myname)
strings aFiles = strsplit(fileread,"\n")
#aFiles
loop i=1..nelem(aFiles)
if strlen(aFiles[i])>0
string myname = path ~ strstrip(aFiles[i])
string fileread = readfile(myname)
#...
#...
endif
endloop
Thanks for the report.
I see you're splitting the contents of TestCrashFile.txt on the
newline character, "\n". However, the file is in old-style Mac
format: it doesn't contain any newline characters, the line-ending
is plain "\r". That means that strsplit() just returns the entire
string -- which ends up overflowing the buffer available for forming
the filename "myname".
So it's understandable that the script won't work (you should use
"\r" with strsplit in this case), but gretl should not crash
regardless. I'm working on blocking the overflow so that this
problem should yield an error report instead of a crash. A fix
should be in place later today.
Allin