Skip to content

Commit

Permalink
work around Chrome bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Jan 26, 2016
1 parent a2ba927 commit 96fcf42
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/am_view_template.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,29 @@ static void AM_CONCAT(TNAME,_view_set_from_table)(lua_State *L, am_buffer_view *
uint8_t *ptr = buf->data + start_offset;
uint8_t *end = buf->data + end_offset;
int j = 1;
int t;
while (ptr < end) {
lua_rawgeti(L, idx, j);
#ifdef VEC_SZ
t = am_get_type(L, -1);
int t = am_get_type(L, -1);
#else
t = lua_type(L, -1);
int t = lua_type(L, -1);
#endif
if (t == LUA_TYPE) {
*((CTYPE*)ptr) = GET_CTYPE(L, -1);
lua_pop(L, 1);
ptr += stride;
j++;
} else if (t == LUA_TNIL) {
lua_pop(L, 1);
break;
} else {
luaL_error(L, "unexpected %s in table at index %d (expecting only %ss)",
am_get_typename(L, t), j, am_get_typename(L, LUA_TYPE));
return;
if (t != LUA_TYPE) {
//The following crashes Chrome 47.0.2526.106 (64-bit):
//if (t == LUA_TNIL) {
if (lua_isnil(L, -1)) {
lua_pop(L, 1);
break;
} else {
luaL_error(L, "unexpected %s in table at index %d (expecting only %ss)",
am_get_typename(L, t), j, am_get_typename(L, LUA_TYPE));
return;
}
}
*((CTYPE*)ptr) = GET_CTYPE(L, -1);
lua_pop(L, 1);
ptr += stride;
j++;
}
buf->mark_dirty(start_offset, start_offset + (j-2) * stride + sizeof(CTYPE));
}
Expand Down

0 comments on commit 96fcf42

Please sign in to comment.