lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm not sure if this qualifies as a bug, but lua_pushcclosure doesn't verify
that the upvalues actually exist on the stack.  If they don't then invalid
values will be put on the stack for the function call, causing a crash if
they are accessed.  Following is an example.

-John


  int callhandler( lua_State* L )
  {
    printf( "%s\n", lua_type(L, -1) );
    return 0;
  }

  int main()
  {
    lua_State* L = lua_open( 0 );
    lua_baselibopen( L );
    lua_pushcclosure( L, callhandler, 1 );  // oops
    lua_setglobal( L, "crasher" );
    lua_dostring( L, "print('hi'); crasher(); print('bye');" );
  }