소스 검색

Small issue in 'exprstat'

The code should not compute an instruction address before checking that
it exists. (Virtually no machine complains of computing an invalid
address, as long as the address is not used, but for ISO C that is
undefined behavior.)
Roberto Ierusalimschy 5 년 전
부모
커밋
cac075a122
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      lparser.c

+ 2 - 1
lparser.c

@@ -1822,8 +1822,9 @@ static void exprstat (LexState *ls) {
     restassign(ls, &v, 1);
     restassign(ls, &v, 1);
   }
   }
   else {  /* stat -> func */
   else {  /* stat -> func */
-    Instruction *inst = &getinstruction(fs, &v.v);
+    Instruction *inst;
     check_condition(ls, v.v.k == VCALL, "syntax error");
     check_condition(ls, v.v.k == VCALL, "syntax error");
+    inst = &getinstruction(fs, &v.v);
     SETARG_C(*inst, 1);  /* call statement uses no results */
     SETARG_C(*inst, 1);  /* call statement uses no results */
   }
   }
 }
 }