aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lbaselib.c12
-rw-r--r--lmem.c5
-rw-r--r--lmem.h6
-rw-r--r--ltable.c10
4 files changed, 14 insertions, 19 deletions
diff --git a/lbaselib.c b/lbaselib.c
index ccc3123a..ce868ef7 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.270 2011/11/23 17:29:04 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.271 2011/11/29 15:55:08 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -297,14 +297,10 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
297 *size = 0; 297 *size = 0;
298 return NULL; 298 return NULL;
299 } 299 }
300 else if ((s = lua_tostring(L, -1)) != NULL) { 300 else if ((s = lua_tostring(L, -1)) == NULL)
301 lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
302 return lua_tolstring(L, RESERVEDSLOT, size);
303 }
304 else {
305 luaL_error(L, "reader function must return a string"); 301 luaL_error(L, "reader function must return a string");
306 return NULL; /* to avoid warnings */ 302 lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
307 } 303 return lua_tolstring(L, RESERVEDSLOT, size);
308} 304}
309 305
310 306
diff --git a/lmem.c b/lmem.c
index 1ee7f23d..2f5cddd5 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.81 2010/12/20 19:40:07 roberto Exp roberto $ 2** $Id: lmem.c,v 1.82 2011/09/20 19:25:23 roberto Exp roberto $
3** Interface to Memory Manager 3** Interface to Memory Manager
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -63,9 +63,8 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
63} 63}
64 64
65 65
66void *luaM_toobig (lua_State *L) { 66l_noret luaM_toobig (lua_State *L) {
67 luaG_runerror(L, "memory allocation error: block too big"); 67 luaG_runerror(L, "memory allocation error: block too big");
68 return NULL; /* to avoid warnings */
69} 68}
70 69
71 70
diff --git a/lmem.h b/lmem.h
index 710a4904..276bb32a 100644
--- a/lmem.h
+++ b/lmem.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.h,v 1.35 2009/12/16 16:42:58 roberto Exp roberto $ 2** $Id: lmem.h,v 1.36 2010/04/08 17:16:46 roberto Exp roberto $
3** Interface to Memory Manager 3** Interface to Memory Manager
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -17,7 +17,7 @@
17#define luaM_reallocv(L,b,on,n,e) \ 17#define luaM_reallocv(L,b,on,n,e) \
18 ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 18 ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
19 luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 19 luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
20 luaM_toobig(L)) 20 (luaM_toobig(L), NULL))
21 21
22#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 22#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
23#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 23#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
@@ -37,7 +37,7 @@
37#define luaM_reallocvector(L, v,oldn,n,t) \ 37#define luaM_reallocvector(L, v,oldn,n,t) \
38 ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 38 ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
39 39
40LUAI_FUNC void *luaM_toobig (lua_State *L); 40LUAI_FUNC l_noret luaM_toobig (lua_State *L);
41 41
42/* not to be called directly */ 42/* not to be called directly */
43LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 43LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
diff --git a/ltable.c b/ltable.c
index 6ded0d93..86bfa792 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.65 2011/09/30 12:45:27 roberto Exp roberto $ 2** $Id: ltable.c,v 2.66 2011/11/28 17:25:48 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -141,7 +141,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
141 return i-1; /* yes; that's the index (corrected to C) */ 141 return i-1; /* yes; that's the index (corrected to C) */
142 else { 142 else {
143 Node *n = mainposition(t, key); 143 Node *n = mainposition(t, key);
144 do { /* check whether `key' is somewhere in the chain */ 144 for (;;) { /* check whether `key' is somewhere in the chain */
145 /* key may be dead already, but it is ok to use it in `next' */ 145 /* key may be dead already, but it is ok to use it in `next' */
146 if (luaV_rawequalobj(gkey(n), key) || 146 if (luaV_rawequalobj(gkey(n), key) ||
147 (ttisdeadkey(gkey(n)) && iscollectable(key) && 147 (ttisdeadkey(gkey(n)) && iscollectable(key) &&
@@ -151,9 +151,9 @@ static int findindex (lua_State *L, Table *t, StkId key) {
151 return i + t->sizearray; 151 return i + t->sizearray;
152 } 152 }
153 else n = gnext(n); 153 else n = gnext(n);
154 } while (n); 154 if (n == NULL)
155 luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ 155 luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
156 return 0; /* to avoid warnings */ 156 }
157 } 157 }
158} 158}
159 159