Coder Social home page Coder Social logo

Bug in luaL_setfuncs about md5 HOT 5 CLOSED

lunarmodules avatar lunarmodules commented on August 22, 2024
Bug in luaL_setfuncs

from md5.

Comments (5)

tomasguisasola avatar tomasguisasola commented on August 22, 2024
Hi Philipp

Thanks.  I've just corrected it.  I am also contributing this

correction to Compat-5.2 (I think yours have a bug also: lua_settable(L,
-3), because lua_pushccloseure pops the upvalues from the stack.

Thanks,
    Tomás

On Fri, 20 Sep 2013, Philipp Janda wrote:

luaL_setfuncs in src/compat-5.2.c doesn't work if nups > 0. See keplerproject/lua-compat-5.2@adf9db4a5. Currently you don't need upvalues for this module, so this is not a pressing issue ...


Reply to this email directly or view it on GitHub:
#4

from md5.

siffiejoe avatar siffiejoe commented on August 22, 2024

I believe my version was correct (and my tests agree with me):
The initial layout when luaL_setfuncs(L, l, 2) is called:
table|up1|up2
then after lua_pushstring:
table|up1|up2|name
then after the loop pushing all upvalues:
table|up1|up2|name|up1|up2
then after the lua_pushcclosure call:
table|up1|up2|name|closure
So for the lua_settable index we have to skip the name, the closure, and the upvalues to get the table ...
The table is at -5 which is -(nups+3)!

from md5.

tomasguisasola avatar tomasguisasola commented on August 22, 2024
Hi Philipp

Sure, you were right from the begining.  Please forgive my

stubbornness.

Regards,
    Tomás

On Sat, 21 Sep 2013, Philipp Janda wrote:

I believe my version was correct (and my tests agree with me):
The initial layout when luaL_setfuncs(L, l, 2) is called:
table|up1|up2
then after lua_pushstring:
table|up1|up2|name
then after the loop pushing all upvalues:
table|up1|up2|name|up1|up2
then after the lua_pushcclosure call:
table|up1|up2|name|closure
So for the lua_settable index we have to skip the name, the closure, and the upvalues to get the table ...
The table is at -5 which is -(nups+3)!


Reply to this email directly or view it on GitHub:
#4 (comment)

from md5.

siffiejoe avatar siffiejoe commented on August 22, 2024

No problem :-)
Btw., the lua_settable(L, -(nup + 3)) was your code to begin with ...

from md5.

tomasguisasola avatar tomasguisasola commented on August 22, 2024
Hi Philipp

On Mon, 23 Sep 2013, Philipp Janda wrote:

No problem :-)
Thanks,

Btw., the lua_settable(L, -(nup + 3)) was your code to begin with ...
In fact, it was a careless translation of the original
implementation of luaL_setfuncs from Lua 5.2.0 code. It just happened
to be right by accident :-)

Regards,
    Tomás

from md5.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.