aboutsummaryrefslogtreecommitdiff
path: root/src/lj_bcread.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lj_bcread.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lj_bcread.c b/src/lj_bcread.c
index 1585272f..1d9547be 100644
--- a/src/lj_bcread.c
+++ b/src/lj_bcread.c
@@ -47,7 +47,7 @@ static LJ_NOINLINE void bcread_error(LexState *ls, ErrMsg em)
47/* Refill buffer. */ 47/* Refill buffer. */
48static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need) 48static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need)
49{ 49{
50 lua_assert(len != 0); 50 lj_assertLS(len != 0, "empty refill");
51 if (len > LJ_MAX_BUF || ls->c < 0) 51 if (len > LJ_MAX_BUF || ls->c < 0)
52 bcread_error(ls, LJ_ERR_BCBAD); 52 bcread_error(ls, LJ_ERR_BCBAD);
53 do { 53 do {
@@ -57,7 +57,7 @@ static LJ_NOINLINE void bcread_fill(LexState *ls, MSize len, int need)
57 MSize n = (MSize)(ls->pe - ls->p); 57 MSize n = (MSize)(ls->pe - ls->p);
58 if (n) { /* Copy remainder to buffer. */ 58 if (n) { /* Copy remainder to buffer. */
59 if (sbuflen(&ls->sb)) { /* Move down in buffer. */ 59 if (sbuflen(&ls->sb)) { /* Move down in buffer. */
60 lua_assert(ls->pe == sbufP(&ls->sb)); 60 lj_assertLS(ls->pe == sbufP(&ls->sb), "bad buffer pointer");
61 if (ls->p != p) memmove(p, ls->p, n); 61 if (ls->p != p) memmove(p, ls->p, n);
62 } else { /* Copy from buffer provided by reader. */ 62 } else { /* Copy from buffer provided by reader. */
63 p = lj_buf_need(&ls->sb, len); 63 p = lj_buf_need(&ls->sb, len);
@@ -107,7 +107,7 @@ static LJ_AINLINE uint8_t *bcread_mem(LexState *ls, MSize len)
107{ 107{
108 uint8_t *p = (uint8_t *)ls->p; 108 uint8_t *p = (uint8_t *)ls->p;
109 ls->p += len; 109 ls->p += len;
110 lua_assert(ls->p <= ls->pe); 110 lj_assertLS(ls->p <= ls->pe, "buffer read overflow");
111 return p; 111 return p;
112} 112}
113 113
@@ -120,7 +120,7 @@ static void bcread_block(LexState *ls, void *q, MSize len)
120/* Read byte from buffer. */ 120/* Read byte from buffer. */
121static LJ_AINLINE uint32_t bcread_byte(LexState *ls) 121static LJ_AINLINE uint32_t bcread_byte(LexState *ls)
122{ 122{
123 lua_assert(ls->p < ls->pe); 123 lj_assertLS(ls->p < ls->pe, "buffer read overflow");
124 return (uint32_t)(uint8_t)*ls->p++; 124 return (uint32_t)(uint8_t)*ls->p++;
125} 125}
126 126
@@ -128,7 +128,7 @@ static LJ_AINLINE uint32_t bcread_byte(LexState *ls)
128static LJ_AINLINE uint32_t bcread_uleb128(LexState *ls) 128static LJ_AINLINE uint32_t bcread_uleb128(LexState *ls)
129{ 129{
130 uint32_t v = lj_buf_ruleb128(&ls->p); 130 uint32_t v = lj_buf_ruleb128(&ls->p);
131 lua_assert(ls->p <= ls->pe); 131 lj_assertLS(ls->p <= ls->pe, "buffer read overflow");
132 return v; 132 return v;
133} 133}
134 134
@@ -145,7 +145,7 @@ static uint32_t bcread_uleb128_33(LexState *ls)
145 } while (*p++ >= 0x80); 145 } while (*p++ >= 0x80);
146 } 146 }
147 ls->p = (char *)p; 147 ls->p = (char *)p;
148 lua_assert(ls->p <= ls->pe); 148 lj_assertLS(ls->p <= ls->pe, "buffer read overflow");
149 return v; 149 return v;
150} 150}
151 151
@@ -192,7 +192,7 @@ static void bcread_ktabk(LexState *ls, TValue *o)
192 o->u32.lo = bcread_uleb128(ls); 192 o->u32.lo = bcread_uleb128(ls);
193 o->u32.hi = bcread_uleb128(ls); 193 o->u32.hi = bcread_uleb128(ls);
194 } else { 194 } else {
195 lua_assert(tp <= BCDUMP_KTAB_TRUE); 195 lj_assertLS(tp <= BCDUMP_KTAB_TRUE, "bad constant type %d", tp);
196 setpriV(o, ~tp); 196 setpriV(o, ~tp);
197 } 197 }
198} 198}
@@ -214,7 +214,7 @@ static GCtab *bcread_ktab(LexState *ls)
214 for (i = 0; i < nhash; i++) { 214 for (i = 0; i < nhash; i++) {
215 TValue key; 215 TValue key;
216 bcread_ktabk(ls, &key); 216 bcread_ktabk(ls, &key);
217 lua_assert(!tvisnil(&key)); 217 lj_assertLS(!tvisnil(&key), "nil key");
218 bcread_ktabk(ls, lj_tab_set(ls->L, t, &key)); 218 bcread_ktabk(ls, lj_tab_set(ls->L, t, &key));
219 } 219 }
220 } 220 }
@@ -251,7 +251,7 @@ static void bcread_kgc(LexState *ls, GCproto *pt, MSize sizekgc)
251#endif 251#endif
252 } else { 252 } else {
253 lua_State *L = ls->L; 253 lua_State *L = ls->L;
254 lua_assert(tp == BCDUMP_KGC_CHILD); 254 lj_assertLS(tp == BCDUMP_KGC_CHILD, "bad constant type %d", tp);
255 if (L->top <= bcread_oldtop(L, ls)) /* Stack underflow? */ 255 if (L->top <= bcread_oldtop(L, ls)) /* Stack underflow? */
256 bcread_error(ls, LJ_ERR_BCBAD); 256 bcread_error(ls, LJ_ERR_BCBAD);
257 L->top--; 257 L->top--;
@@ -422,7 +422,7 @@ static int bcread_header(LexState *ls)
422GCproto *lj_bcread(LexState *ls) 422GCproto *lj_bcread(LexState *ls)
423{ 423{
424 lua_State *L = ls->L; 424 lua_State *L = ls->L;
425 lua_assert(ls->c == BCDUMP_HEAD1); 425 lj_assertLS(ls->c == BCDUMP_HEAD1, "bad bytecode header");
426 bcread_savetop(L, ls, L->top); 426 bcread_savetop(L, ls, L->top);
427 lj_buf_reset(&ls->sb); 427 lj_buf_reset(&ls->sb);
428 /* Check for a valid bytecode dump header. */ 428 /* Check for a valid bytecode dump header. */