diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-08-28 19:34:05 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-08-28 19:34:05 -0400 |
commit | 364ea79ab3a4d48e0d10fbeabb9b8e88f226baac (patch) | |
tree | 6948ed4b35ca006087673ff7af8fcdd08b8d6d51 /indra | |
parent | 14c8fc3768d978205bf17ffc1905c2772afbd434 (diff) |
Prevent erroneous assignment to LL.setdtor() proxy._target field.
Trim redundant output from test_setdtor.lua.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/lua_function.cpp | 4 | ||||
-rw-r--r-- | indra/newview/scripts/lua/test_setdtor.lua | 28 |
2 files changed, 17 insertions, 15 deletions
diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp index 12cff89fbd..f61cf3fe10 100644 --- a/indra/llcommon/lua_function.cpp +++ b/indra/llcommon/lua_function.cpp @@ -1050,7 +1050,7 @@ lua_function( } // called with (desc, obj, dtor), returns proxy object lua_checkdelta(L, -2); - lluau_checkstack(L, 3); // might get up to 6 stack entries +// lluau_checkstack(L, 0); // might get up to 3 stack entries auto desc{ lua_tostdstring(L, 1) }; // Get Lua "references" for each of the object and the dtor function. int objref = lua_ref(L, 2); @@ -1150,6 +1150,8 @@ void setdtor_refs::push_metatable(lua_State* L) return (lhs._target <= rhs._target) end, __newindex = function(t, key, value) + assert(key ~= '_target', + "Don't try to replace a setdtor() proxy's _target") t._target[key] = value end, __call = function(func, ...) diff --git a/indra/newview/scripts/lua/test_setdtor.lua b/indra/newview/scripts/lua/test_setdtor.lua index 743c5168d0..61ed86dcc8 100644 --- a/indra/newview/scripts/lua/test_setdtor.lua +++ b/indra/newview/scripts/lua/test_setdtor.lua @@ -7,6 +7,7 @@ print('arithmetic') n = LL.setdtor('arithmetic', 11, print) print("n =", n) print("n._target =", n._target) +print(pcall(function() n._target = 12 end)) print("getmetatable(n) =", inspect(getmetatable(n))) print("-n =", -n) for i = 10, 12 do @@ -20,20 +21,19 @@ for i = 10, 12 do print(`n >= {i}`, n >= tempi) print(`n > {i}`, n > tempi) end -for i = 2, 3 do - print(`n + {i} =`, n + i) - print(`{i} + n =`, i + n) - print(`n - {i} =`, n - i) - print(`{i} - n =`, i - n) - print(`n * {i} =`, n * i) - print(`{i} * n =`, i * n) - print(`n / {i} =`, n / i) - print(`{i} / n =`, i / n) - print(`n % {i} =`, n % i) - print(`{i} % n =`, i % n) - print(`n ^ {i} =`, n ^ i) - print(`{i} ^ n =`, i ^ n) -end +i = 2 +print(`n + {i} =`, n + i) +print(`{i} + n =`, i + n) +print(`n - {i} =`, n - i) +print(`{i} - n =`, i - n) +print(`n * {i} =`, n * i) +print(`{i} * n =`, i * n) +print(`n / {i} =`, n / i) +print(`{i} / n =`, i / n) +print(`n % {i} =`, n % i) +print(`{i} % n =`, i % n) +print(`n ^ {i} =`, n ^ i) +print(`{i} ^ n =`, i ^ n) print('string') s = LL.setdtor('string', 'hello', print) |