Skip to content

Commit 4317381

Browse files
authored
[fuzzer] Avoid infinite loop in weighted_pick (#131)
1 parent a311bc2 commit 4317381

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/fuzzer/expr_gen.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,11 @@ Enum weighted_pick(
13851385

13861386
RealType running_sum = 0;
13871387
for (size_t i = 0; i < array.size(); i++) {
1388-
running_sum += mask[i] ? array[i] : 0;
1388+
if (!mask[i]) {
1389+
continue;
1390+
}
1391+
1392+
running_sum += array[i];
13891393
if (choice <= running_sum) {
13901394
return (Enum)i;
13911395
}

0 commit comments

Comments
 (0)