[0.2-2] fixed a bunch of crash bugs + arch specific bugs

dev
Ben Russell (300178622) 2015-02-03 20:59:20 +13:00
parent efa973cfc2
commit 676ac1529e
5 changed files with 44 additions and 32 deletions

View File

@ -23,7 +23,7 @@
#define VERSION_X 2
#define VERSION_Y 0
#define VERSION_A 0
#define VERSION_Z 1
#define VERSION_Z 2
// Remember to bump "Z" basically every time you change the engine!
// Remember to bump the version in Lua too!
// Remember to document API changes in a new version!

View File

@ -20,9 +20,9 @@
-- Thanks. --GM
VERSION_ENGINE = {
cmp={0,2,0,0,1},
num=8388608+1,
str="0.2-1",
cmp={0,2,0,0,2},
num=8388608+2,
str="0.2-2",
}
-- 0.1: 4194304
@ -133,5 +133,8 @@ VERSION_BUGS = {
{intro=nil, fix=4259840+12, msg="Frame delay in client.hook_tick doesn't work properly - Frame limiter will not work"},
{intro=nil, fix=4259840+14, msg="Network serialisation broken on ARM"},
{intro=nil, fix=8388608+1, msg="Local code cannot write to clsave/pub"},
{intro=nil, fix=8388608+2, msg="JSON writer crashes on 64-bit builds"},
{intro=nil, fix=8388608+2, msg="tcp_connect crashes on address failure"},
{intro=nil, fix=8388608+2, msg="argb_spit_to_merged broken on ARM"},
}

View File

@ -572,7 +572,7 @@ int json_write_number(lua_State *L, FILE *fp)
*/
int json_write_string(lua_State *L, FILE *fp)
{
unsigned int len;
size_t len;
const char* c = lua_tolstring(L, -1, (size_t *)&len);
fwrite("\"", 1, 1, fp);
for(; len > 0; --len)
@ -593,8 +593,9 @@ int json_write_string(lua_State *L, FILE *fp)
fwrite("\\t", 2, 1, fp);
else if(!isprint(*c))
{
char* buf = (char*) malloc(6);
sprintf(buf, "\\u%4.4X", *((unsigned char*) c));
// TODO: handle unicode
char buf[20];
sprintf(buf, "\\u%04X", *((unsigned char*) c));
fwrite(buf, 6, 1, fp);
}
else
@ -627,6 +628,7 @@ int json_write_string(lua_State *L, FILE *fp)
int json_write_table(lua_State *L, FILE *fp)
{
fwrite("{\r\n", 3, 1, fp);
luaL_checkstack(L, 2, "json_write_table failed to expand stack");
lua_pushnil(L);
if (lua_next(L, -2))
{
@ -646,6 +648,7 @@ int json_write_table(lua_State *L, FILE *fp)
}
fwrite("}", 1, 1, fp);
lua_pop(L, 1);
luaL_checkstack(L, -2, "json_write_table failed to contract stack");
return 0;
}
@ -665,6 +668,7 @@ int json_write_table(lua_State *L, FILE *fp)
*/
int json_write_array(lua_State *L, FILE *fp)
{
luaL_checkstack(L, 2, "json_write_array failed to expand stack");
fwrite("[", 1, 1, fp);
lua_pushnil(L);
if (lua_next(L, -2))
@ -678,6 +682,7 @@ int json_write_array(lua_State *L, FILE *fp)
}
fwrite("]", 1, 1, fp);
lua_pop(L, 1);
luaL_checkstack(L, -2, "json_write_array failed to contract stack");
return 0;
}

View File

@ -49,7 +49,11 @@ int icelua_fn_common_tcp_connect(lua_State *L) {
snprintf(port_ch, 17, "%u", port);
getaddrinfo(host, port_ch, &hints, &res);
if(getaddrinfo(host, port_ch, &hints, &res) != 0)
{
if(res != NULL) freeaddrinfo(res);
return 0;
}
sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
ret = connect(sockfd, res->ai_addr, res->ai_addrlen);

View File

@ -1,29 +1,29 @@
/*
This file is part of Iceball.
This file is part of Iceball.
Iceball is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Iceball is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Iceball is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Iceball is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Iceball. If not, see <http://www.gnu.org/licenses/>.
*/
int icelua_fn_common_argb_split_to_merged(lua_State *L)
{
int top = icelua_assert_stack(L, 3, 4);
lua_pushinteger(L,
((lua_tointeger(L, 1) & 0xFF) << 16) |
((lua_tointeger(L, 2) & 0xFF) << 8) |
((lua_tointeger(L, 3) & 0xFF)) |
((top < 4 ? 0xFF : (lua_tointeger(L, 4) & 0xFF)) << 24));
lua_pushnumber(L, (double)(
((lua_tointeger(L, 1) & 0xFF) << 16) |
((lua_tointeger(L, 2) & 0xFF) << 8) |
((lua_tointeger(L, 3) & 0xFF)) |
(((uint32_t)(top < 4 ? 0xFF : (lua_tointeger(L, 4) & 0xFF))) << 24)));
return 1;
}
@ -31,13 +31,13 @@ int icelua_fn_common_argb_split_to_merged(lua_State *L)
int icelua_fn_common_argb_merged_to_split(lua_State *L)
{
int top = icelua_assert_stack(L, 1, 1);
uint32_t c = lua_tointeger(L, 1);
lua_pushinteger(L, (c >> 24));
lua_pushinteger(L, (c >> 16) & 0xFF);
lua_pushinteger(L, (c >> 8) & 0xFF);
lua_pushinteger(L, (c) & 0xFF);
uint32_t c = lua_tointeger(L, 1);
lua_pushinteger(L, (c >> 24));
lua_pushinteger(L, (c >> 16) & 0xFF);
lua_pushinteger(L, (c >> 8) & 0xFF);
lua_pushinteger(L, (c) & 0xFF);
return 4;
}