@@ -96,9 +96,10 @@ int luaG_getfuncline (const Proto *f, int pc) {
9696 else {
9797 int basepc;
9898 int baseline = getbaseline (f, pc, &basepc);
99- while (basepc++ < pc) { /* walk until given instruction */
100- lua_assert (lineInfoSpan[basepc] != ABSLINEINFO);
101- baseline += lineInfoSpan[basepc]; /* correct line */
99+ /* Walk from basepc+1 to pc (inclusive), accumulating line deltas */
100+ for (size_t i = static_cast <size_t >(basepc + 1 ); i <= static_cast <size_t >(pc); i++) {
101+ lua_assert (lineInfoSpan[i] != ABSLINEINFO);
102+ baseline += lineInfoSpan[i]; /* correct line */
102103 }
103104 return baseline;
104105 }
@@ -295,12 +296,12 @@ static void funcinfo (lua_Debug *ar, Closure *cl) {
295296
296297
297298// Phase 115.2: Use span accessors
298- static int nextline (const Proto *p, int currentline, int pc) {
299+ static int nextline (const Proto *p, int currentline, size_t pc) {
299300 auto lineInfoSpan = p->getDebugInfo ().getLineInfoSpan ();
300301 if (lineInfoSpan[pc] != ABSLINEINFO)
301302 return currentline + lineInfoSpan[pc];
302303 else
303- return luaG_getfuncline (p, pc );
304+ return luaG_getfuncline (p, static_cast < int >(pc) );
304305}
305306
306307
@@ -317,7 +318,7 @@ static void collectvalidlines (lua_State *L, Closure *f) {
317318 api_incr_top (L);
318319 auto lineInfoSpan = p->getDebugInfo ().getLineInfoSpan ();
319320 if (!lineInfoSpan.empty ()) { /* proto with debug information? */
320- int i;
321+ size_t i;
321322 TValue v;
322323 setbtvalue (&v); /* boolean 'true' to be the value of all indices */
323324 if (!(p->getFlag () & PF_ISVARARG)) /* regular function? */
@@ -328,7 +329,7 @@ static void collectvalidlines (lua_State *L, Closure *f) {
328329 currentline = nextline (p, currentline, 0 );
329330 i = 1 ; /* skip first instruction (OP_VARARGPREP) */
330331 }
331- for (; i < static_cast < int >( lineInfoSpan.size () ); i++) { /* for each instruction */
332+ for (; i < lineInfoSpan.size (); i++) { /* for each instruction */
332333 currentline = nextline (p, currentline, i); /* get its line */
333334 luaH_setint (L, t, currentline, &v); /* table[line] = true */
334335 }
@@ -953,13 +954,14 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
953954 return 0 ;
954955 if (newpc - oldpc < MAXIWTHABS / 2 ) { /* not too far apart? */
955956 int delta = 0 ; /* line difference */
956- int pc = oldpc;
957+ size_t pc = static_cast < size_t >( oldpc) ;
957958 for (;;) {
958- int lineinfo = lineInfoSpan[++pc];
959+ ++pc;
960+ int lineinfo = lineInfoSpan[pc];
959961 if (lineinfo == ABSLINEINFO)
960962 break ; /* cannot compute delta; fall through */
961963 delta += lineinfo;
962- if (pc == newpc)
964+ if (static_cast < int >(pc) == newpc)
963965 return (delta != 0 ); /* delta computed successfully */
964966 }
965967 }
0 commit comments