|
Diego Nehab wrote:
Hi Bill,As a fix I've simply put a test around the above code like this: if (alias) { while (*alias) { lua_pushnumber(L, i); lua_pushstring(L, *alias); lua_settable(L, -3); i++; alias++; } } The above fix works but I'm not sure if it is the best solution within the design of luasocket; perhaps a fix deeper in the socket hierarchy (e.g. usocket.c) would be better.Seems hard to fix it within usocket.c. I don't object to your approach andI am happy to prevent LuaSocket from crashing anywhere possible. Thanks, Diego.
Now that I see this I remember another similar error. gethostbyname and gethostbyaddr return a pointer to NULL when they fail and (should) set h_errno to something. My operating system does the first but forgets to set h_errno. sock_gethostbyaddr and sock_gethostbyname use 0 as a success return code and the routine returned to uses the NULL pointer and blows up. The line: else return h_errno; should probably at least contain an assertion that h_errno != IO_DONE to alert possible porters to the real cause of their problems as soon as possible. /Brian