Fixes shorten string called with not number value (#7259)

This commit is contained in:
Matteo Biscosi 2023-02-27 10:29:17 +00:00
parent 69e4ebc852
commit d4fe237404
2 changed files with 14 additions and 8 deletions

View file

@ -402,6 +402,12 @@ function shortenString(name, max_len)
if(max_len == nil) then max_len = 24 end
end
-- Error, max_len is not a number, print an error and return the name
if not tonumber(max_len) then
traceError(TRACE_DEBUG, TRACE_CONSOLE, "Length parameter is not a number.")
tprint(debug.traceback())
return name
end
if(string.len(name) < max_len + 1 --[[ The space taken by the ellipsis --]]) then
return(name)
else