modules/lua_utils.lua: enforce checks on version before doing ariths

This commit lets the version2int() function better check types
and convertibility before performing arithmetics to get the
version hash.
This commit is contained in:
Arianna Avanzini 2015-06-12 15:48:36 +02:00
parent 9c0364d385
commit 2aac293316

View file

@ -1090,9 +1090,9 @@ function version2int(v)
minor = e[2]
veryminor = e[3]
if(major == nil or type(major) ~= "string") then major = 0 end
if(minor == nil or type(minor) ~= "string") then minor = 0 end
if(veryminor == nil or type(veryminor) ~= "string") then veryminor = 0 end
if(major == nil or tonumber(major) == nil or type(major) ~= "string") then major = 0 end
if(minor == nil or tonumber(minor) == nil or type(minor) ~= "string") then minor = 0 end
if(veryminor == nil or tonumber(veryminor) == nil or type(veryminor) ~= "string") then veryminor = 0 end
version = tonumber(major)*1000 + tonumber(minor)*100 + tonumber(veryminor)
return(version)