Skip to content

Commit

Permalink
[compiler] Throw error after 500 includes
Browse files Browse the repository at this point in the history
  • Loading branch information
5pilow committed Jun 14, 2023
1 parent c49585d commit ac4910c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/leekscript/compiler/bloc/MainLeekBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import leekscript.compiler.instruction.ClassDeclarationInstruction;
import leekscript.compiler.instruction.LeekGlobalDeclarationInstruction;
import leekscript.runner.LeekFunctions;
import leekscript.common.Error;

public class MainLeekBlock extends AbstractLeekBlock {

Expand Down Expand Up @@ -138,6 +139,10 @@ public boolean includeAIFirstPass(WordCompiler compiler, String path) throws Lee
if (mIncludedFirstPass.contains(ai)) {
return true;
}
// Hack dégueu à retirer, crash du daemon dans un cas précis d'include infini
if (mIncludedFirstPass.size() > 500) {
throw new LeekCompilerException(compiler.getParser().token(), Error.UNKNOWN_ERROR);
}
ai.clearErrors();
mIncludedFirstPass.add(ai);
var previousAI = mCompiler.getCurrentAI();
Expand All @@ -160,6 +165,10 @@ public boolean includeAI(WordCompiler compiler, String path) throws LeekCompiler
if (mIncluded.contains(ai)) {
return true;
}
// Hack dégueu à retirer, crash du daemon dans un cas précis d'include infini
if (mIncluded.size() > 500) {
throw new LeekCompilerException(compiler.getParser().token(), Error.UNKNOWN_ERROR);
}
// ai.clearErrors();
mIncluded.add(ai);
var previousAI = mCompiler.getCurrentAI();
Expand Down

0 comments on commit ac4910c

Please sign in to comment.