Skip to content

Commit

Permalink
fix(sendInLoop): Stack overflow on large contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Oct 31, 2024
1 parent 3c31e7f commit 74a89c4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/detectors/builtin/sendInLoop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { CompilationUnit } from "../../internals/ir";
import { foldStatements, foldExpressions, isSelf } from "../../internals/tact";
import {
forEachStatement,
foldExpressions,
isSelf,
} from "../../internals/tact";
import { MistiTactWarning, Severity } from "../../internals/warnings";
import { ASTDetector } from "../detector";
import {
Expand Down Expand Up @@ -38,18 +42,16 @@ export class SendInLoop extends ASTDetector {

async check(cu: CompilationUnit): Promise<MistiTactWarning[]> {
const processedLoopIds = new Set<number>();
return Array.from(cu.ast.getProgramEntries()).reduce((acc, node) => {
return acc.concat(
...foldStatements(
node,
(acc, stmt) => {
return acc.concat(this.analyzeStatement(stmt, processedLoopIds));
},
acc,
{ flatStmts: true },
),
);
}, [] as MistiTactWarning[]);
const allWarnings: MistiTactWarning[] = [];

Array.from(cu.ast.getProgramEntries()).forEach((node) => {
forEachStatement(node, (stmt) => {
const warnings = this.analyzeStatement(stmt, processedLoopIds);
allWarnings.push(...warnings);
});
});

return allWarnings;
}

private analyzeStatement(
Expand Down

0 comments on commit 74a89c4

Please sign in to comment.